stream-chat-react-native icon indicating copy to clipboard operation
stream-chat-react-native copied to clipboard

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".

Open flyaflya opened this issue 1 year ago • 0 comments

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 avatar Jan 04 '24 16:01 flyaflya