Replace mock notifications with real-time Firestore listener (fixes #639)#644
Open
Priyanka0205-CSE wants to merge 2 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Closes #639
While investigating this issue, I found that
NotificationBell.jsxdoesn't exist as a separate component, and the notification bell inNavbar.jsxwas rendering staticmockNotificationsdata with no Firestore listener at all — so the originally-described cleanup bug didn't apply to the current codebase.I repurposed the issue to implement the real thing: a live, Firestore-backed notification system with correct listener lifecycle handling built in from the start.
Changes
mockNotificationsimport and static data usageonSnapshotlistener onusers/{uid}/notifications, ordered bycreatedAt[user?.uid]dependency array and is properly unsubscribed on unmount/auth changemarkAllAsRead,deleteNotification, andclearAllNotificationsnow write directly to Firestore instead of only updating local stateTesting
npm run devbuilds cleanly with no console errors from the new codeuseris null (logged out / Firebase not configured locally) — falls into the early-return branch and clears local stateNotes
users/{uid}/notificationssubcollection. Populating that collection (e.g. triggering a notification doc on follow/comment events) is out of scope here and could be a follow-up.