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

groupStyles mislabels messages whose create time is sufficiently after the previous message and that follow "single" messages. Labelled "Bottom" when should be "top" or "single". #2374

Open
flyaflya opened this issue Jan 4, 2024 · 0 comments

Comments

@flyaflya
Copy link

flyaflya commented Jan 4, 2024

Issue

The logic for groupStyles mislabels messages where the previous message is "single" and the difference in the current and previous messages' create time is longer than the maxTimeBetweenGroupedMessages.

These messages should be labelled either "Top" or "Single", but they are getting labelled as "bottom".

I believe the code can be fixed by adding the last line to this code snippet:

    const isTopMessage =
      !previousMessage ||
      previousMessage.type === 'system' ||
      userId !== previousMessage?.user?.id ||
      previousMessage.type === 'error' ||
      !!isPrevMessageTypeDeleted ||
      (!hideDateSeparators && dateSeparators[message.id]) ||
      messageGroupStyles[previousMessage.id]?.includes('bottom') ||
      messageGroupStyles[previousMessage.id]?.includes('single');   //new line to fix bug

I have testted this fix by sending a fixed component, getMessagesGroupStyles={getGroupStyles} and it seems to work perfectly.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a chat with Channel prop of maxTimeBetweenGroupedMessages={40000}
  2. Add a single message from a specific user
  3. Wait more than 40 seconds.
  4. Add another message from the same user.
  5. Note the groupStyle on the last created message is "bottom"... it should be "single".
@flyaflya flyaflya changed the title groupStyles mislabels messages whose create time is sufficiently after the previous message and that following "single" messages. Labelled "Bottom" When should be "top" or "single". groupStyles mislabels messages whose create time is sufficiently after the previous message and that follow "single" messages. Labelled "Bottom" When should be "top" or "single". Jan 4, 2024
@flyaflya flyaflya changed the title groupStyles mislabels messages whose create time is sufficiently after the previous message and that follow "single" messages. Labelled "Bottom" When should be "top" or "single". groupStyles mislabels messages whose create time is sufficiently after the previous message and that follow "single" messages. Labelled "Bottom" when should be "top" or "single". Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant