-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: register first unread message id on message.new & when initializing Channel state #1211
Conversation
… on new own or thread messages
…zing Channel state
Size Change: +915 B (0%) Total Size: 329 kB
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use this algorithm:https://www.notion.so/stream-wiki/Mark-Unread-Developer-Specs-3b05e4fb069a4e2b9355216a5e6085a2?pvs=4#04bc470a33e249c6ba9e7e6c8d6c9279? That algorithm computes first_unread_message_id
based on last_read_message_id
so we would have to run that algorithm whenever the last_read_message_id
can change, which are these places based on the code:
message.read
eventnotification.mark_unread
event_initializeState
function
I have tested that |
Did you find a scenario where the implementation based on It also feels more consistent, even though it's possible your algorithm does the same as iOS but it's hard to compare the two . |
I
I personally have some read states in queried channels without |
But this is expected, and the iOS algorithm handles it ( |
So you are suggesting to use |
No, I'm suggesting to use the algorithm that iOS has implemented. In the case I'm trying to understand why we aren't using the algorithm specified in the Notion document. You mentioned the edge case of |
I have considered the fact that Scenario 3 relies on Scenario 1. Scenario 1 requires knowledge of whether all messages have been loaded. JS client does not handle pagination and so it does not have information about whether more messages can be queried. The algorithm in this PR covers all what iOS spec mentions. An exception could be Scenario 1 - we do not have |
It will be unnecessary to calculate first unread message id. If not available at the moment of jumping to the first unread message, it will be determined as a message following the last read message. |
Description of the changes, What, Why and How?
To achieve consistency in the UI concerning the display of unread messages indicators, we need to provide the
first_unread_message_id
value consistently. The value is not provided when querying channels, neither when a new message arrives. Therefore, we have to calculate it client-side.In this PR we register the
first_unread_message_id
inmessage.new
handler and inChannel._initializeState()
. The latter is invoked every time aChannel
instance is created or channel data is queried from the BE. InChannel._initializeState()
we inspect the whole message set and not only the recently queried messages.This PR also removes dead code, that was anyways overwritten on the following lines.