fix(mail): refresh threads when any mailbox count changes - #381
Open
s-aga-r wants to merge 1 commit into
Open
Conversation
The 30s poll gated the thread-list refresh on total_threads alone, so a reply landing in an existing thread (which moves only unread_threads / total_emails) updated the sidebar badge without ever invoking get_threads, leaving the list stale. - serialize total_emails/unread_emails in get_mailboxes (the Mailbox doctype already stores them) and compare all four counts in the poll - update already-loaded threads in place during a refresh merge so the refetched row (new snippet, unread state, timestamp) is actually shown instead of being discarded by the prepend-only merge Fixes frappe#171
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.
Fixes #171
Problem
The 30-second poll in
MailboxView.vuegated the thread-list refresh ontotal_threadsalone. A reply arriving into an existing thread changes onlyunread_threads/total_emails— so the sidebar badge updated (fromget_mailboxes) whileget_threadswas never invoked and the list went stale. Read-state changes from another device/session hit the same gap.Changes
get_mailboxesnow also serializestotal_emailsandunread_emails(already stored on the Mailbox doctype from JMAP'stotalEmails/unreadEmails) — these change for any new message, including a read reply into a read thread, which no thread-level count can catch.pollForChangescompares a composite key of all four counts instead oftotal_threadsalone.onResetSuccess): already-loaded threads now take their fresh row (new snippet, unread state, timestamp) in place instead of being discarded by the prepend-only merge — without this, the refetch triggered by the poll fix would fetch the updated row and then throw it away. Rows keep their position (no re-sort), so the list doesn't jump under the reader. This also benefits the existing socket-driven refresh path, which had the same blind spot.Verification
thread_idstrings and row keys, not object identity.Known residual limitation: changes between two polls that net out to identical counts (e.g. one arrival + one deletion in the same 30s window) still won't trigger a refresh; catching that would need a JMAP state-token comparison, which is a larger change.
🤖 Generated with Claude Code