Fix email thread polling causing duplicate messages#16
Merged
Neverdecel merged 1 commit intomainfrom Jan 25, 2026
Merged
Conversation
The JavaScript polling logic used complex DOM manipulation that caused messages to be appended instead of replaced, leading to duplicates appearing in the thread view. After a manual page refresh, everything displayed correctly. Changes: - Replace DOM manipulation with simple page reload on new messages - Track messages by ID instead of array index for accurate detection - This eliminates the duplicate message bug entirely The page reload approach is simpler and more reliable than trying to surgically update the DOM while maintaining correct newest-first order.
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.
Summary
Problem
When sending a message in the email thread:
Root Cause
The JavaScript polling logic used
innerHTMLmanipulation and array index-based comparison that caused messages to be appended incorrectly, leading to duplicates. The messages are displayed newest-first, but the old logic assumed oldest-first ordering.Solution
Changed the polling behavior to:
This is simpler and more reliable than trying to surgically update the DOM.
Testing
DevOps Notes
No infrastructure changes required. This is a frontend-only fix in a Jinja2 template.