Open
Conversation
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.
Hopefully this is a fix for #242 which has been around since 2022. I still experience this frequently, so (as much as I hate to admit it) I asked Claude and this is what it came back with. I don't do Java at all - but it seemed to be pretty confident this was the issue. Maybe worth a shot to see if it finally resolves the issue, and hopefully makes more sense to you than me?
The race condition: When the user opens the app via a notification, two things happen near-simultaneously:
onResume()registers the broadcast receiver and launchesupdateMissedMessages(), which fetches missed messages from the server via HTTPnotifyMissedNotifications(), which re-broadcasts those same missed messages — which the now-registered receiver picks up and adds viaaddSingleMessage()Both paths call
addMessages()→newMessage()→addMessage()for the same set of messages. Since there was no duplicate guard, each message got inserted twice.The fix adds an
id-based existence check before inserting into either list (ALL_MESSAGESor the app-specific list), so the second insertion of any already-present message is silently skipped.