Skip to content

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

Description

@flyaflya

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions