@checkstack/notification-frontend 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @checkstack/notification-frontend
2
2
 
3
+ ## 0.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8a87cd4]
8
+ - @checkstack/common@0.5.0
9
+ - @checkstack/auth-frontend@0.5.2
10
+ - @checkstack/frontend-api@0.3.2
11
+ - @checkstack/notification-common@0.2.2
12
+ - @checkstack/ui@0.3.1
13
+ - @checkstack/signal-frontend@0.0.9
14
+
15
+ ## 0.2.6
16
+
17
+ ### Patch Changes
18
+
19
+ - 5ac15df: Fixed notification count badge not updating correctly when notifications are marked as read.
20
+
21
+ **Root Cause:** When the `NOTIFICATION_READ` signal was received, `signalUnreadCount` state was `undefined` (only set from signals, not initial query data), so it incorrectly defaulted to `1` instead of the actual count from the query. This caused the count to jump to `0` after the first mark-as-read.
22
+
23
+ **Fix:** Now uses `unreadData?.count` as the fallback value when decrementing the count in the signal handler.
24
+
3
25
  ## 0.2.5
4
26
 
5
27
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/notification-frontend",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -53,7 +53,7 @@ export const NotificationBell = () => {
53
53
  {
54
54
  enabled: !!session && isOpen,
55
55
  staleTime: 30_000,
56
- }
56
+ },
57
57
  );
58
58
 
59
59
  // Mark all as read mutation
@@ -88,7 +88,7 @@ export const NotificationBell = () => {
88
88
  },
89
89
  ...(prev ?? []).slice(0, 4), // Keep only 5 items
90
90
  ]);
91
- }, [])
91
+ }, []),
92
92
  );
93
93
 
94
94
  // Handle count changes from other sources
@@ -96,25 +96,31 @@ export const NotificationBell = () => {
96
96
  NOTIFICATION_COUNT_CHANGED,
97
97
  useCallback((payload) => {
98
98
  setSignalUnreadCount(payload.unreadCount);
99
- }, [])
99
+ }, []),
100
100
  );
101
101
 
102
102
  // Handle notification marked as read
103
103
  useSignal(
104
104
  NOTIFICATION_READ,
105
- useCallback((payload) => {
106
- if (payload.notificationId) {
107
- // Single notification marked as read - remove from list
108
- setSignalNotifications((prev) =>
109
- (prev ?? []).filter((n) => n.id !== payload.notificationId)
110
- );
111
- setSignalUnreadCount((prev) => Math.max(0, (prev ?? 1) - 1));
112
- } else {
113
- // All marked as read - clear the list
114
- setSignalNotifications([]);
115
- setSignalUnreadCount(0);
116
- }
117
- }, [])
105
+ useCallback(
106
+ (payload) => {
107
+ if (payload.notificationId) {
108
+ // Single notification marked as read - remove from list
109
+ setSignalNotifications((prev) =>
110
+ (prev ?? []).filter((n) => n.id !== payload.notificationId),
111
+ );
112
+ // Use unreadData?.count as fallback when signalUnreadCount hasn't been set yet
113
+ setSignalUnreadCount((prev) =>
114
+ Math.max(0, (prev ?? unreadData?.count ?? 1) - 1),
115
+ );
116
+ } else {
117
+ // All marked as read - clear the list
118
+ setSignalNotifications([]);
119
+ setSignalUnreadCount(0);
120
+ }
121
+ },
122
+ [unreadData?.count],
123
+ ),
118
124
  );
119
125
 
120
126
  // ==========================================================================
@@ -208,8 +214,8 @@ export const NotificationBell = () => {
208
214
  notification.importance === "critical"
209
215
  ? "border-l-2 border-l-destructive"
210
216
  : notification.importance === "warning"
211
- ? "border-l-2 border-l-warning"
212
- : ""
217
+ ? "border-l-2 border-l-warning"
218
+ : ""
213
219
  }`}
214
220
  >
215
221
  <div
@@ -217,8 +223,8 @@ export const NotificationBell = () => {
217
223
  notification.importance === "critical"
218
224
  ? "text-destructive"
219
225
  : notification.importance === "warning"
220
- ? "text-warning"
221
- : "text-foreground"
226
+ ? "text-warning"
227
+ : "text-foreground"
222
228
  }`}
223
229
  >
224
230
  {notification.title}