Repository navigation
Count unread in channels you haven't opened, from when you joined (GRYT-1977) - #352
Merged
Merged
Conversation
…YT-1977) The server only counted unread from a read marker, and a marker only exists once you've opened the channel. So a channel you'd never opened showed no badge however much arrived. It now counts from when you joined. Anybody who joined before this upgrade counts from the upgrade, so old messages don't light up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 server only counted unread from a read marker, and you only get a marker by opening the channel. So a channel you'd never opened showed no badge however much arrived in it.
Now the moment you joined is the starting point. Older messages count as read and newer ones as unread. Opening the channel creates a marker, and the normal count takes over. This is all on the server, so desktop and web get it with no client change, because
setServerUnreadalready takes a count for a channel with no marker. The phone needs mobile#462, which addsread:list.I didn't write a marker per channel at join. That would need a write on every join and on every new channel. This reads
users.created_atinstead and writes nothing.Look at:
server_config.unread_fromis new, indb/sqlite/connection.ts, which is why this needs your review. The migration sets it to the time of the upgrade, so people who are already members count from then. Without it, everyone's unopened channels would fill up with old messages on day one. A fresh database leaves it null and uses the join date.sendStatenow also runs the unopened count andvisibleChannelIds, and that happens on everyread:set, so once per message landing in an open channel. I haven't measured it on a big database. The query goes throughidx_messages_conv_time.created_at, so an unopened channel counts from their first join. That can be a big number. I left it.Tested:
readMarkers.test.tson a real database: messages before and after joining, your own messages, thread replies, a DM id, handing over to the marker, andunread_from. The socket test checks a channel you can't read stays out of the reply, and it fails if I remove that filter. I ran the migration on a database without the column: it sets the time once and keeps it on the next start.Not tested: the badge on a real client. mobile#462 isn't merged, and I haven't run this with the desktop app.
GRYT-1977
🤖 Generated with Claude Code