fix: Filter DeleteMessage when computing the oldest loaded message [WPB-3506] #15686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The bug
loading a conversation that contains a
DeleteMessage
that hasn't been seen yet by the user will not show messages after this deleted messageThe problem
When messages arrives for a conversation that is not currently viewed by the user, we stack those messages in the
messages
property of the conversation.When the user clicks on a conversation to view, these are the steps that are triggered to load the messages we want to display to them:
messages
list;messages
listThis logic works pretty fine, except for
DeleteMessage
which can have a timestamp in the past.Since delete messages timestamp are actually the timestamp of the message that was deleted.
An example
let's say we have a conversation between user1 and user2 with those messages:
user1, is not currently looking at this conversation (so no messages are loaded into memory).
message1
.delete
event and store it in themessages
listmessage1
which has a timestamp of0
.0
The fix
We computing the
oldest
message, we should not considerdelete
messages as we cannot trust their timestamp