fix: prevent duplicate streak achievement notifications (#13325) #15550
+250
−0
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 #13325
Problem
Users were receiving duplicate streak achievement notifications (often 2-3 identical notifications) when earning a streak milestone. Each duplicate had to be dismissed separately, causing UX friction.
Reported behavior:
Root Cause
The issue occurs at two levels:
STREAK_ACHIEVEMENTnotifications in the cleanup processSolution
Server-Side Fix (
website/server/models/userNotification.js)cleanupCorruptData()function_.uniqWith()to remove duplicateSTREAK_ACHIEVEMENTnotificationsNEW_CHAT_MESSAGEdeduplicationClient-Side Fix (
website/client/src/components/notifications.vue)lastShownStreakCountproperty to track displayed streak achievementsuser.achievements.streakbefore showing notificationTesting (
test/api/unit/models/userNotification.test.js)NEW_CHAT_MESSAGEdeduplication still worksChanges
website/server/models/userNotification.js- Server-side deduplicationwebsite/client/src/components/notifications.vue- Client-side duplicate preventiontest/api/unit/models/userNotification.test.js- Added unit testsDUPLICATE_STREAK_FIX.md- Implementation documentationTesting Instructions
npm test test/api/unit/models/userNotification.test.jsImpact
UUID: c2669fd4-edcb-4757-98d6-31d239ce6abe