Skip to content

Realtime inbox badge updates — decrement unread count when notifications are marked read#415

Closed
SachinSingh008 wants to merge 1 commit into
frappe:developfrom
SachinSingh008:develop
Closed

Realtime inbox badge updates — decrement unread count when notifications are marked read#415
SachinSingh008 wants to merge 1 commit into
frappe:developfrom
SachinSingh008:develop

Conversation

@SachinSingh008
Copy link
Copy Markdown

Fix: Realtime inbox badge updates — decrement unread count when notifications are marked read

Summary

Unread notification count in the sidebar did not decrement after opening/marking a notification as read until a full page reload. This adds a realtime refetch on notification updates so the count updates immediately.

Changes

  • Add on_update to GPNotification to publish refetch_resource for Unread Notifications Count when read changes (with a safe fallback when read is set).

Rationale

  • New notifications were already triggering realtime via after_insert, but marking as read had no corresponding event. Emitting a refetch on read state change keeps the badge accurate without reloads.

Testing

  • Create a notification for a user; verify sidebar shows count = 1.
  • Open the notification or click “Mark as read”.
  • Observe the sidebar “Inbox” badge decrements to 0 without reloading.
  • Repeat across multiple browser tabs; all tabs should update in realtime.

Notes

  • Frontend already listens for refetch_resource and reloads Unread Notifications Count, so no UI changes were needed.
  • Wrapped in try/except to avoid save failures if realtime publish fails.

@netchampfaris
Copy link
Copy Markdown
Contributor

Fixed in #478

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants