Skip to content

Commit b65024a

Browse files
committed
fix(notifications): scope unread state per user to restore correct bell badge counts across roles
1 parent 02be074 commit b65024a

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/app/core/notifications/activity-notification.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AuthService } from '../auth/services/auth.service';
77
import { TaskStatus } from '../api/models/task-status.enum';
88
import { Subscription } from 'rxjs';
99

10-
const LAST_READ_STORAGE_KEY = 'task_management.notifications.last_read_at';
10+
const LAST_READ_STORAGE_KEY_PREFIX = 'task_management.notifications.last_read_at';
1111
const NOTIFICATION_LIMIT = 50;
1212

1313
export interface ActivityNotificationItem {
@@ -185,7 +185,7 @@ export class ActivityNotificationService {
185185
}
186186

187187
private readLastReadAtMs(): number {
188-
const value = localStorage.getItem(LAST_READ_STORAGE_KEY);
188+
const value = localStorage.getItem(this.getLastReadStorageKey());
189189
if (!value) {
190190
return 0;
191191
}
@@ -195,6 +195,15 @@ export class ActivityNotificationService {
195195
}
196196

197197
private writeLastReadAt(value: string): void {
198-
localStorage.setItem(LAST_READ_STORAGE_KEY, value);
198+
localStorage.setItem(this.getLastReadStorageKey(), value);
199+
}
200+
201+
private getLastReadStorageKey(): string {
202+
const userId = this.authService.currentUserId();
203+
if (!userId || userId.trim().length === 0) {
204+
return `${LAST_READ_STORAGE_KEY_PREFIX}.anonymous`;
205+
}
206+
207+
return `${LAST_READ_STORAGE_KEY_PREFIX}.${userId}`;
199208
}
200209
}

0 commit comments

Comments
 (0)