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

Deleting first message of day removes date separator for sender

Open hankwz opened this issue 2 years ago • 3 comments

We have a customization that hides all the deleted messages for both sender and receiver in chat using the following in the Channel component from stream-chat-react-native

deletedMessagesVisibilityType={'never'}

When sender deleted the first message of day, the date separator is also deleted for the remaining messages of the day.

  • Package version stream-chat-react-native: 4.3.1
  • react-native: 0.66.4
  • iOS 15.2 simulator and Android 11 emulator

To Reproduce

  1. Send 2 messages on a new date
  2. Delete the first message

Expected behavior The date separator should display when first message of the day is deleted

File

hankwz avatar May 09 '22 17:05 hankwz

@hankwz thanks for bringing this up. I am able to reproduce this issue on our end, we will fix it as soon as we can.

vishalnarkhede avatar May 09 '22 19:05 vishalnarkhede

Issue

While inserting the date separators, we filter out the deleted messages ... except if the deleted message is from current logged in user (current user). - https://github.com/GetStream/stream-chat-react-native/blob/develop/package/src/components/MessageList/utils/getDateSeparators.ts#L33

Although this assumes that deleted messages will always be visible to current user, which was the case for v3 (and prior versions). Since v4 we introduced a prop deletedMessagesVisibilityType to customize the visibility of deleted messages. Thus if the value of this prop is either never or receiver, then we should filter out the current user's messages as well.

Scope

Change the .filter() logic to following:

  const messagesWithoutDeleted = messages.filter((message) => {
    const isMessageTypeDeleted = message.type === 'deleted';
    const isDeleteMessageVisibleToSender =
      deletedMessagesVisibilityType === 'sender' || deletedMessagesVisibilityType === 'always';

    return !isMessageTypeDeleted || (userId === message.user?.id && isDeleteMessageVisibleToSender);
  });

vishalnarkhede avatar May 23 '22 15:05 vishalnarkhede

Hey team! Please add your planning poker estimate with ZenHub @Enigma-I-am @khushal87 @madsroskar @santhoshvai @vishalnarkhede

vanGalilea avatar May 24 '22 08:05 vanGalilea

:tada: This issue has been resolved in version 5.3.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

vishalnarkhede avatar Sep 22 '22 13:09 vishalnarkhede