Skip to content
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

Browser persistence lastId should not rely on timestamp #37

Open
singpolyma opened this issue Nov 26, 2024 · 0 comments
Open

Browser persistence lastId should not rely on timestamp #37

singpolyma opened this issue Nov 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@singpolyma
Copy link
Collaborator

timestamp is the time the message was sent (that is, it takes into account delay tags). So getting lastId by this means that sometimes we get a non-last id and thus end up fetching messages we already have. That's not fatal, but in a Channel it means we end up with the wrong unread count because the Channel sync code assumes any messages it gets from the sync are new and thus unread.

We could solve this by re-querying the store to get the unread count after sync. This might be safer due to race conditions of live messages arriving during sync operations. (Unless we switch to a sync-first approach, but that has race conditions that can lead to lost messages...)

OTOH lastId being based on timestamp is clearly wrong. It probably shouldn't be based on any timestamps at all, but since we aren't promised MAM ids are sortable we get into the thorny issue of producing our own sortable ids locally which is possible but we have not done yet.

@singpolyma singpolyma added the bug Something isn't working label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant