bug: Admin sidebar Sponsorship badge count doesn't update after approving a pending profile #115

Closed
opened 2026-05-11 16:51:51 +00:00 by spikerj · 1 comment
Owner

Problem

In the Admin panel, the sidebar shows a red badge next to Sponsorship indicating the number of pending profile approvals. After approving all pending sponsorship profiles (the "Pending Approval" tab shows "No Pending Profiles — All sponsorship profiles have been reviewed"), the badge count in the sidebar does not decrement or disappear. It still shows the stale count (e.g. 1) making it look like there are still profiles waiting for review when there aren't.

Expected behavior

After approving (or rejecting) a pending sponsorship profile, the Sponsorship badge count in the admin sidebar should immediately update to reflect the new pending count. When all pending profiles have been reviewed, the badge should disappear entirely (or show 0 and hide).

Steps to reproduce

  1. Navigate to Admin > Sponsorship (badge shows a count, e.g. 1).
  2. Go to the "Pending Approval" tab.
  3. Approve the pending profile(s).
  4. Observe the tab now says "No Pending Profiles".
  5. Look at the sidebar — the Sponsorship badge still shows the old count.

Likely cause

The sidebar badge count is fetched on page load (or admin shell init) but is not re-fetched or decremented in response to the approve/reject action. The approval handler needs to either:

  • Emit an event / update a signal that the sidebar subscribes to, OR
  • Re-query the pending count after a successful approval and push the new value into the badge signal.
## Problem In the Admin panel, the sidebar shows a red badge next to **Sponsorship** indicating the number of pending profile approvals. After approving all pending sponsorship profiles (the "Pending Approval" tab shows "No Pending Profiles — All sponsorship profiles have been reviewed"), the badge count in the sidebar does **not** decrement or disappear. It still shows the stale count (e.g. `1`) making it look like there are still profiles waiting for review when there aren't. ## Expected behavior After approving (or rejecting) a pending sponsorship profile, the Sponsorship badge count in the admin sidebar should immediately update to reflect the new pending count. When all pending profiles have been reviewed, the badge should disappear entirely (or show `0` and hide). ## Steps to reproduce 1. Navigate to Admin > Sponsorship (badge shows a count, e.g. `1`). 2. Go to the "Pending Approval" tab. 3. Approve the pending profile(s). 4. Observe the tab now says "No Pending Profiles". 5. Look at the sidebar — the Sponsorship badge still shows the old count. ## Likely cause The sidebar badge count is fetched on page load (or admin shell init) but is not re-fetched or decremented in response to the approve/reject action. The approval handler needs to either: - Emit an event / update a signal that the sidebar subscribes to, OR - Re-query the pending count after a successful approval and push the new value into the badge signal.
Author
Owner

Fix Implemented

Root cause confirmed: no SignalR event was being pushed to the client after approving/revoking a sponsorship profile, so the badge count in the menu bar stayed stale.

Changes (3 files)

Backend — SponsorController.cs

  • Injected INotificationService into the controller
  • After ApproveSponsorProfile completes, sends a sponsor.pending_approval notification via SendToAllAsync to the system-notifications SignalR group
  • After RevokeSponsorApproval completes, does the same
  • Added NotifySponsorPendingCountChangedAsync() helper (mirrors BookController.NotifyPendingApprovalCountChangedAsync)

Frontend — system-notification.service.ts

  • Added pendingSponsorApprovalChanged signal
  • In the ReceiveNotification handler, increments the signal when notification.type === "sponsor.pending_approval"

Frontend — menu-bar.component.ts

  • Added _sponsorApprovalEffect that watches pendingSponsorApprovalChanged() and calls sponsorService.refreshPendingSponsorCount() for staff/admin users

This follows the exact same pattern already established for book approval badge updates (pendingBookApprovalChanged_bookApprovalEffectbookService.refreshPendingApprovalCount()). All admin/staff users with the app open will get real-time badge updates when any admin approves or revokes a profile.

## Fix Implemented Root cause confirmed: no SignalR event was being pushed to the client after approving/revoking a sponsorship profile, so the badge count in the menu bar stayed stale. ### Changes (3 files) **Backend — `SponsorController.cs`** - Injected `INotificationService` into the controller - After `ApproveSponsorProfile` completes, sends a `sponsor.pending_approval` notification via `SendToAllAsync` to the `system-notifications` SignalR group - After `RevokeSponsorApproval` completes, does the same - Added `NotifySponsorPendingCountChangedAsync()` helper (mirrors `BookController.NotifyPendingApprovalCountChangedAsync`) **Frontend — `system-notification.service.ts`** - Added `pendingSponsorApprovalChanged` signal - In the `ReceiveNotification` handler, increments the signal when `notification.type === "sponsor.pending_approval"` **Frontend — `menu-bar.component.ts`** - Added `_sponsorApprovalEffect` that watches `pendingSponsorApprovalChanged()` and calls `sponsorService.refreshPendingSponsorCount()` for staff/admin users This follows the exact same pattern already established for book approval badge updates (`pendingBookApprovalChanged` → `_bookApprovalEffect` → `bookService.refreshPendingApprovalCount()`). All admin/staff users with the app open will get real-time badge updates when any admin approves or revokes a profile.
Sign in to join this conversation.