Skip to content

fix: Duplicated notifications#446

Open
axllent wants to merge 1 commit intogotify:masterfrom
axllent:duplicates
Open

fix: Duplicated notifications#446
axllent wants to merge 1 commit intogotify:masterfrom
axllent:duplicates

Conversation

@axllent
Copy link
Copy Markdown

@axllent axllent commented Apr 24, 2026

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:

  1. onResume() registers the broadcast receiver and launches updateMissedMessages(), which fetches missed messages from the server via HTTP
  2. The WebSocket reconnects (common when the phone was sleeping/offline) and calls notifyMissedNotifications(), which re-broadcasts those same missed messages — which the now-registered receiver picks up and adds via addSingleMessage()

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_MESSAGES or the app-specific list), so the second insertion of any already-present message is silently skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant