Skip to content

fix: persist unread notification count across refreshes#1116

Merged
Priyanshu-byte-coder merged 3 commits into
Priyanshu-byte-coder:mainfrom
seffhunnn:fix/notification-badge-refresh-flicker
May 27, 2026
Merged

fix: persist unread notification count across refreshes#1116
Priyanshu-byte-coder merged 3 commits into
Priyanshu-byte-coder:mainfrom
seffhunnn:fix/notification-badge-refresh-flicker

Conversation

@seffhunnn
Copy link
Copy Markdown
Contributor

Summary

Fixed the unread notification badge flicker after page refresh by persisting the last known unread count in localStorage and restoring it immediately on initial render before the client-side fetch completes.

Closes #1031

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Added localStorage persistence for unread notification count
  • Restored cached unread count on initial client render
  • Added validation for invalid/non-numeric cached values
  • Added SSR-safe guards for localStorage access
  • Updated cache after successful notification fetches
  • Prevented notification badge flicker on hard refresh

How to Test

Steps for the reviewer to verify this works:

  1. Run the project locally using npm run dev
  2. Ensure there are unread notifications available
  3. Refresh the dashboard page using Ctrl + R
  4. Verify the notification badge appears immediately without flickering to 0
  5. Open DevTools → Network and enable Slow 3G
  6. Refresh the page again and verify the cached unread count appears before the fetch completes
  7. Open DevTools → Application → Local Storage
  8. Verify devtrack:unread-notification-count is stored correctly
  9. Run the following in the browser console:
    localStorage.setItem("devtrack:unread-notification-count", "abc")
  10. Refresh the page and verify the app safely falls back to 0 without crashing
  11. Run npm run lint
  12. Run npm run type-check

Screenshots (if UI change)

N/A

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@seffhunnn is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels May 25, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) gssoc:approved GSSoC: PR approved for scoring labels May 26, 2026
@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Playwright smoke tests are failing on this PR. Check the CI logs, fix failing tests, then push an update. Cannot merge while tests are red.

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Playwright smoke tests are failing on this PR. Please check the E2E test failures and fix them before merging.

@github-actions github-actions Bot added the type:devops GSSoC type bonus: devops (+15 pts) label May 26, 2026
@seffhunnn
Copy link
Copy Markdown
Contributor Author

hii @Priyanshu-byte-coder i synced the latest playwright workflow fixes into this branch, verified that the ci issue was caused by the previous playwright version mismatch, and confirmed that e2e tests, lint, and type checks are now all passing successfully.

@Priyanshu-byte-coder Priyanshu-byte-coder merged commit 84f0116 into Priyanshu-byte-coder:main May 27, 2026
10 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Merged! Thanks for contributing to DevTrack.

If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers.

Keep an eye on open issues for your next contribution!

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

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) type:bug GSSoC type bonus: bug fix type:devops GSSoC type bonus: devops (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: notification bell badge count resets on page refresh

2 participants