Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Поправить код #9

Open
gsbelarus opened this issue May 1, 2023 · 1 comment
Open

Поправить код #9

gsbelarus opened this issue May 1, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@gsbelarus
Copy link
Owner

gsbelarus commented May 1, 2023

  return (
    !isLoading && user.userId &&
    <>
      {/* {
        (chatInfo?.owner === userId) && 
        <div>
          <Input onChange={e => setParticipantId(e.target.value)}/>
          <Button onClick={handleAddParticipant}>Add participant</Button>
        </div>
        
      } */}
      {
          chatInfo.participants.includes(user.userId) && 
          <>
            <h3>{chatInfo.tag}</h3>
            <ChatView nlpDialog={nlpDialog} info={{chatId: chatInfo._id, user}}/>
          </>
        }
    </>  
  )

это лишнее усложнение кода. понятнее написать так:

  if (!isLoading && user.userId && chatInfo.participants.includes(user.userId)) {
    return(
      <>
         <h3>{chatInfo.tag}</h3>
         <ChatView nlpDialog={nlpDialog} info={{chatId: chatInfo._id, user}}/>
      </>          
    )
  }

  return null;

и если дальше смотреть, то заголовок чата должен быть внутри компонента ChatView, а не отдельно снаружи.

@gsbelarus gsbelarus added the enhancement New feature or request label May 1, 2023
@maisiukartyom
Copy link
Contributor

Но ведь будет же добавлен код, который сейчас закоменчен, например, несколько проверок будет

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants