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

reply_count from Thread did not remove deleted message when flag hideDeletedMessage is used

Open neopit opened this issue 2 years ago • 4 comments

Describe the bug

On a ThreadList (message list ...), it is possible to provide props for hiding the delete message (https://getstream.io/chat/docs/sdk/react/components/core-components/virtualized_list/#hidedeletedmessages).

When we enabled this feature then the reply_count counter is still returning the number of replies and continue to count deleted messages.

To Reproduce

  1. Configure the <Thread /> component for showing the deleted messages
  2. Create 2 messages in the <Thread />
  3. Now delete a message in the Thread -> a bubble indicates the message is deleted and the number of replies = 2

run the app again now with hideDeletedMessages=true on the <Thread /> component

  1. Configure the same <Thread /> (hideDeletedMessages=true) for hiding the delete message.
  2. Go back in the Thread (the bubble of the deleted messages disappeared) BUT the number of replies is still 2.

We expect to see only one reply because all deleted messages are hiding

Important: The MessageList shows as well the number of reply_count and it is incorrect on the message list as well.

Expected behavior

When the hideDeletedMessages is true then we expect reply_count to avoid counting deleted messages

Screenshots

If applicable, add screenshots to help explain your problem.

Package version

  • stream-chat-react: v10.7.2
  • stream-chat-css: N/A
  • stream-chat-js: N/A

Desktop (please complete the following information): All platforms, all browsers, all OS

Smartphone (please complete the following information):

  • All devices

Additional context

Screenshot 2023-03-15 at 2 54 51 PM Screenshot 2023-03-15 at 2 55 06 PM

neopit avatar Mar 15 '23 19:03 neopit

@neopit thank you for reporting this. We are working on the fix.

MartinCupela avatar Mar 16 '23 14:03 MartinCupela

@neopit we will not be able to solve this issue immediately. For this to happen, we need some changes on the API side. For the moment, if your priority is the consistency, I would recommend not to use the flag hideDeletedMessages.

MartinCupela avatar Mar 16 '23 14:03 MartinCupela

@MartinCupela I discovered something else, it looks like the rules are not similar between Mobile (react-native project) and web (react project).

On react-native, the deleted messages are not counted but on the react project the deleted messages are counted. So it seems the rule is not similar between the 2 projects.

I believe the react-native is correct, if a message is deleted (hidden or not) then it does not have to be counted as a reply. From this and if agreed, the fix on the web would be easier and would not need any API change I believe.

neopit avatar Mar 21 '23 18:03 neopit

@neopit the RN SDK is using directly the reply_count value from the message object. That is the same, what the React SDK does. As the JS client is not receiving information about the deleted messages in the main message list, it cannot adjust the resulting count. Also, if you open a thread with let's say 1K messages, the client still does not get the information about the total number of deleted messages (as only a fraction of messages is retrieved and then pagination takes place).

This feature needs API support to work reliably.

MartinCupela avatar Apr 03 '23 09:04 MartinCupela