Do not send read requests for notifications already read #3604
No reviewers
Labels
No labels
BE Request
Backlog
Better behavior
Blocked by deps
Bug
Code Review
Discussion
Doing
Feature Request / Enhancement
In the shining bright future maybe
It's complicated
MS Edge
Mememoon (or other niche browsers)
Missing API
Missing feature
Missing l10n/i18n
NL1
NL2
NL4
Need to verify on develop
RELEASE BLOCKER
Reassign or Close
Refactor
Regression
Safari
To Do
User story
Waiting on godot
accessibility
better documentation
chore
confirmed
easy ticket
incident
l10n update
mastoapi
mobile
needs design
needs-info
needs-review
stupid
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
pleroma/pleroma-fe!3604
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/notifications-read-spam"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every click inside a mention notification (expand, link, reply box) sent
POST /api/v1/pleroma/notifications/read, also when the notification was already read. "Mark all as read" and closing the mobile drawer also sent it when nothing was unread. This easily trips rate limits on that endpoint.Now
markSingleNotificationAsSeenskips notifications that are already read, andmarkNotificationsAsSeenskips when all loaded notifications are read.Testing
test/unit/specs/stores/notifications_read_requests.spec.js(fails without the fix)/oc review
opencode-agent:job=170:generation=1
Verdict
No defects introduced by this pull request. Merge-readiness rating: 5/5 — production-ready.
What the change does
src/stores/notifications.js(markSingleNotificationAsSeen): returns early when the notification is alreadyseen, so repeat clicks inside an already-read mention send no furtherPOST /api/v1/pleroma/notifications/readrequests.src/stores/notifications.js(markNotificationsAsSeen): returns early when every loaded notification is alreadyseen, so "mark all as read" and mobile-drawer close send nothing when there is nothing unread.test/unit/specs/stores/notifications_read_requests.spec.jscovers all three behaviors.Why it is correct
seen = truesynchronously before the async API call, so a second click deterministically observes the flag and skips — the "many clicks, one request" test pins this down.this.data, whose entries are the same object references held inidStore, so the two guards cannot disagree about seen-state in normal flow.[].every(...)istrue, so no request with an emptymax_idis sent.notificationInteractedinsrc/components/notifications/notifications.js:227-230; article clicks go throughnotificationClickedinsrc/components/notifications/notifications.js:223-226; drawer close and "mark all" go through the bulk path (src/components/mobile_nav/mobile_nav.js:118-119,src/components/notifications/notifications.js:231-234).seenmarking, no rollback); no new error path is introduced.Validation
test/unit/specs/stores/notifications_read_requests.spec.js: 3/3 passed (vitest browser mode, headless Chromium).test/unit/specs/stores/notifications.spec.js: 17/17 passed, no regressions.