Skip to content

fix: skip channelUnreads update for own messages - #200

Merged
Dadadah merged 1 commit into
stoatchat:mainfrom
onewhobridges:fix/skip-channel-unreads-for-own-message
Oct 15, 2026
Merged

Dadadah merged 1 commit into
stoatchat:mainfrom
onewhobridges:fix/skip-channel-unreads-for-own-message

Conversation

@onewhobridges

Copy link
Copy Markdown
Contributor

This should fix stoatchat/for-web#1713, by changing the Message event handler to skip updating channelUnreads for the user's own messages. This mirrors the behavior of the client that sends the message, which skips processing the Message event entirely due to the !client.messages.has(event._id) check.

Also removed a redundant call to client.channels.updateUnderlyingObject for lastMessageId.

Tested locally using for-web main (8cd48758) and api:v0.15.5.

@Dadadah Dadadah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By omitting the lastMessageID update on messages owned by the user, the channel cannot progress its updatedAt value until someone else sends a message or reload. You will need to update lastMessageID for the user's own messages while also updating the ack (but only update the ack if the previous ack position was owned by the user).

Signed-off-by: onewhobridges <pneumatic.tube.b@gmail.com>
@onewhobridges
onewhobridges force-pushed the fix/skip-channel-unreads-for-own-message branch from 5dd5690 to 5ee5be9 Compare October 14, 2026 23:56
@onewhobridges

onewhobridges commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

lastMessageID must always be updated, got it.

but only update the ack if the previous ack position was owned by the user

I may not fully understand this. I know that we don't want to ack earlier unread messages from other users; my latest commit handles this by only acking the new message if it is the user's own AND channel.unread is false.
Does this achieve the desired behavior, or is there still a scenario where we need to check authorship of the last acked message?

@Dadadah

Dadadah commented Oct 15, 2026

Copy link
Copy Markdown
Member

Yes, acking on that condition is the correct scenario. Thanks for updating, I'll get this reviewed soon.

@Dadadah
Dadadah merged commit 185d537 into stoatchat:main Oct 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"New Message" notification for messages for own messages from another client

2 participants