Conversation
Member
|
I think we generally want this to behave like it behaves in email, where additional click is required. Otherwise, we could provide a different API on backend first, instead of spamming with read requests. However, the conflict handling of running request and mark as read is an important thing that I will merge manually |
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
Mark Activity notifications as read when the user actually sees them, instead of requiring a click through to the corresponding post.
This fixes the case where opening Activity and reading the visible notifications leaves them highlighted in blue as though they had never been seen.
Based on
devat99749cf(fix(community): read now happens before navigation). The upstreambeforeClickcallback and read-before-navigation ordering are preserved; this PR adds automatic viewport-based reading and makes the cached read state reflect successful API acknowledgements.Before / after
dev)activityReadonce at least 50% of it is visible in a visible document. Its blue unread background is removed after the request succeeds.IntersectionObserverchecks actual intersection, so mounting an offscreen overscan card alone does not mark it read.document.visibilityState; returning to the tab checks the currently intersecting cards. Requests already started are not cancelled when the tab becomes hidden.setDetailsreplaces the cached details and can restore an olderisRead: false.Implementation
src/app/activity/page.tsxIntersectionObserver({threshold: 0.5}).visibilitychangeso cards visible when returning to the tab can be acknowledged.beforeClickpath.src/services/activity-service.tsactivity.markRead(app, id), which awaits a successful backend result before updating caches.isRead: truevalues when populating details from a potentially stale list response. This relies on the existing one-way read operation; the current client has no mark-as-unread operation.Reproduction / expected behavior
Verification
Static checks passed on the rebased changes:
pnpm run compilepnpm exec eslint src/app/activity/page.tsx src/services/activity-service.tspnpm exec prettier --check src/app/activity/page.tsx src/services/activity-service.tsgit diff --check origin/dev...HEADBrowser regression checks used the actual
ActivityPageunder React Strict Mode, with a temporary fixture and mocked backend responses:The browser checks were performed locally against mocked responses, not a signed-in production backend. The temporary harness is not included in the PR. No backend API changes or new dependencies are required.