Open
Description
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:
- Create a chat with Channel prop of
maxTimeBetweenGroupedMessages={40000}
- Add a single message from a specific user
- Wait more than 40 seconds.
- Add another message from the same user.
- Note the groupStyle on the last created message is "bottom"... it should be "single".