stream-chat-react-native
stream-chat-react-native copied to clipboard
Deleting first message of day removes date separator for sender
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
- Send 2 messages on a new date
- Delete the first message
Expected behavior The date separator should display when first message of the day is deleted
@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.
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);
});
Hey team! Please add your planning poker estimate with ZenHub @Enigma-I-am @khushal87 @madsroskar @santhoshvai @vishalnarkhede
:tada: This issue has been resolved in version 5.3.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket: