@burdenoff/microfe-notification 2026.1130.2 → 2026.1202.1
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/dist/hooks/answeredAt.d.ts +8 -0
- package/dist/hooks/answeredAt.js +33 -0
- package/dist/hooks/answeredAt.js.map +1 -0
- package/dist/hooks/useNotificationAdmin.d.ts +2 -0
- package/dist/hooks/useNotificationAdmin.js +32 -31
- package/dist/hooks/useNotificationAdmin.js.map +1 -1
- package/dist/hooks/useNotificationPreferences.d.ts +2 -0
- package/dist/hooks/useNotificationPreferences.js +45 -43
- package/dist/hooks/useNotificationPreferences.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +2 -0
- package/dist/hooks/useNotificationTemplates.js +92 -88
- package/dist/hooks/useNotificationTemplates.js.map +1 -1
- package/dist/hooks/useNotificationTopics.d.ts +2 -0
- package/dist/hooks/useNotificationTopics.js +19 -18
- package/dist/hooks/useNotificationTopics.js.map +1 -1
- package/dist/hooks/useNotifications.d.ts +2 -0
- package/dist/hooks/useNotifications.js +69 -68
- package/dist/hooks/useNotifications.js.map +1 -1
- package/dist/hooks/usePreferenceToggles.d.ts +2 -0
- package/dist/hooks/usePreferenceToggles.js +19 -18
- package/dist/hooks/usePreferenceToggles.js.map +1 -1
- package/dist/v2/InboxPage.js +100 -98
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/PreferencesPage.js +98 -92
- package/dist/v2/PreferencesPage.js.map +1 -1
- package/dist/v2/StaleHint.d.ts +4 -0
- package/dist/v2/StaleHint.js +18 -0
- package/dist/v2/StaleHint.js.map +1 -0
- package/dist/v2/admin/DeliveryLogPage.js +71 -69
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -1
- package/dist/v2/admin/TemplatesPage.js +135 -130
- package/dist/v2/admin/TemplatesPage.js.map +1 -1
- package/dist/v2/admin/TopicsPage.js +51 -49
- package/dist/v2/admin/TopicsPage.js.map +1 -1
- package/dist/v2/model/loadedAt.d.ts +5 -0
- package/dist/v2/model/loadedAt.js +8 -0
- package/dist/v2/model/loadedAt.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useNotification as e } from "../providers/NotificationProvider.js";
|
|
2
2
|
import { USER_NOTIFICATION_CONTEXT as t, getGlobalNotificationClient as n } from "../graphql/global-client.js";
|
|
3
3
|
import { useNotificationStore as r } from "../store/notificationStore.js";
|
|
4
|
-
import { appendNotificationPage as i, mergeRefreshedFirstPage as
|
|
5
|
-
import { ArchiveNotificationDocument as
|
|
4
|
+
import { appendNotificationPage as i, mergeRefreshedFirstPage as a, nextNotificationWindow as o } from "./notificationPaging.js";
|
|
5
|
+
import { ArchiveNotificationDocument as s, ArchiveNotificationsDocument as c, GetMyUnreadNotificationCountDocument as l, GetNotificationsDocument as u, MarkAllMyNotificationsAsReadDocument as ee, MarkNotificationAsReadDocument as te, NotificationReceivedDocument as ne, RecordNotificationActionDocument as re, UnarchiveNotificationDocument as d, UnreadCountUpdatedDocument as ie } from "../generated/global-operations.js";
|
|
6
6
|
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
7
7
|
// src/hooks/useNotifications.ts
|
|
8
8
|
function _(e) {
|
|
@@ -115,7 +115,7 @@ function x(e) {
|
|
|
115
115
|
URGENT: "URGENT"
|
|
116
116
|
}[e.priority] || e.priority), e.isRead !== null && e.isRead !== void 0 && (t.isRead = e.isRead), e.topicId && (t.topicId = e.topicId), e.channel && e.channel !== "ALL" && (t.channel = e.channel), e.archived !== null && e.archived !== void 0 && (t.archived = e.archived), e.search && (t.search = e.search), e.dateRange.start && (t.startDate = e.dateRange.start.toISOString()), e.dateRange.end && (t.endDate = e.dateRange.end.toISOString()), Object.keys(t).length > 0 ? t : void 0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function ae(e, t) {
|
|
119
119
|
return t ? {
|
|
120
120
|
...e,
|
|
121
121
|
...t,
|
|
@@ -125,24 +125,24 @@ function S(e, t) {
|
|
|
125
125
|
}
|
|
126
126
|
} : e;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
let { authToken: y, apiGatewayUrl: b, currentUser:
|
|
128
|
+
function S(v = {}) {
|
|
129
|
+
let { authToken: y, apiGatewayUrl: b, currentUser: S, eventBus: C } = e(), { notificationFilter: w, updateNotificationFilter: T, resetNotificationFilter: E, unreadCount: D, setUnreadCount: O, setIsLoadingNotifications: k } = r(), [A, j] = g([]), [oe, se] = g(null), [M, N] = g(!1), [P, F] = g(null), [I, L] = g(!1), [ce, R] = g(0), [le, z] = g(0), [B, V] = g(!1), H = h(!1), U = h(0), W = h(/* @__PURE__ */ new Set()), G = h(0), K = h(!1), q = h([]);
|
|
130
130
|
p(() => {
|
|
131
131
|
q.current = A;
|
|
132
132
|
}, [A]);
|
|
133
|
-
let J = m(() =>
|
|
133
|
+
let J = m(() => ae(w, v.baseFilter), [w, v.baseFilter]), [Y, ue] = g(J);
|
|
134
134
|
p(() => {
|
|
135
|
-
let e = window.setTimeout(() =>
|
|
135
|
+
let e = window.setTimeout(() => ue(J), 250);
|
|
136
136
|
return () => window.clearTimeout(e);
|
|
137
137
|
}, [J]);
|
|
138
138
|
let X = f(() => n(b ?? void 0, y ?? void 0), [b, y]), Z = f(async () => {
|
|
139
139
|
U.current += 1;
|
|
140
140
|
let e = U.current;
|
|
141
|
-
K.current = !0,
|
|
141
|
+
K.current = !0, N(!0), k(!0), F(null);
|
|
142
142
|
try {
|
|
143
143
|
let n = await X().query({
|
|
144
144
|
context: t,
|
|
145
|
-
query:
|
|
145
|
+
query: u,
|
|
146
146
|
variables: {
|
|
147
147
|
filter: x(Y),
|
|
148
148
|
limit: 50,
|
|
@@ -152,13 +152,13 @@ function C(v = {}) {
|
|
|
152
152
|
});
|
|
153
153
|
if (n.data?.notifications && e === U.current) {
|
|
154
154
|
let e = n.data.notifications.items.map(_);
|
|
155
|
-
W.current = new Set(e.map((e) => e.id)), j(e),
|
|
155
|
+
W.current = new Set(e.map((e) => e.id)), j(e), R(n.data.notifications.total), L(n.data.notifications.hasMore), z(Date.now());
|
|
156
156
|
}
|
|
157
157
|
} catch (t) {
|
|
158
158
|
let n = t instanceof Error ? t.message : "Failed to fetch notifications";
|
|
159
|
-
console.error("[useNotifications] Failed to fetch notifications:", t),
|
|
159
|
+
console.error("[useNotifications] Failed to fetch notifications:", t), F(n), e === U.current && L(!1);
|
|
160
160
|
} finally {
|
|
161
|
-
e === U.current && (K.current = !1),
|
|
161
|
+
e === U.current && (K.current = !1), N(!1), k(!1);
|
|
162
162
|
}
|
|
163
163
|
}, [
|
|
164
164
|
Y,
|
|
@@ -168,7 +168,7 @@ function C(v = {}) {
|
|
|
168
168
|
try {
|
|
169
169
|
let e = await X().query({
|
|
170
170
|
context: t,
|
|
171
|
-
query:
|
|
171
|
+
query: l,
|
|
172
172
|
variables: { filter: v.unreadFilter || { channel: "IN_APP" } },
|
|
173
173
|
fetchPolicy: "network-only"
|
|
174
174
|
});
|
|
@@ -180,16 +180,16 @@ function C(v = {}) {
|
|
|
180
180
|
X,
|
|
181
181
|
v.unreadFilter,
|
|
182
182
|
O
|
|
183
|
-
]),
|
|
184
|
-
if (!
|
|
185
|
-
let e =
|
|
183
|
+
]), de = f(async () => {
|
|
184
|
+
if (!I || H.current || K.current) return;
|
|
185
|
+
let e = o(A, W.current, Y);
|
|
186
186
|
if (!e) return;
|
|
187
187
|
H.current = !0, V(!0);
|
|
188
188
|
let n = U.current;
|
|
189
189
|
try {
|
|
190
190
|
let r = await X().query({
|
|
191
191
|
context: t,
|
|
192
|
-
query:
|
|
192
|
+
query: u,
|
|
193
193
|
variables: {
|
|
194
194
|
filter: x({
|
|
195
195
|
...Y,
|
|
@@ -207,18 +207,18 @@ function C(v = {}) {
|
|
|
207
207
|
if (r.data?.notifications) {
|
|
208
208
|
let e = r.data.notifications.items.map(_);
|
|
209
209
|
for (let t of e) W.current.add(t.id);
|
|
210
|
-
j((t) => i(t, e)),
|
|
210
|
+
j((t) => i(t, e)), L(r.data.notifications.hasMore), z(Date.now());
|
|
211
211
|
}
|
|
212
212
|
} catch (e) {
|
|
213
213
|
let t = e instanceof Error ? e.message : "Failed to load more notifications";
|
|
214
|
-
console.error("[useNotifications] Failed to load more:", e),
|
|
214
|
+
console.error("[useNotifications] Failed to load more:", e), F(t);
|
|
215
215
|
} finally {
|
|
216
216
|
H.current = !1, V(!1);
|
|
217
217
|
}
|
|
218
218
|
}, [
|
|
219
219
|
Y,
|
|
220
220
|
X,
|
|
221
|
-
|
|
221
|
+
I,
|
|
222
222
|
A
|
|
223
223
|
]), $ = f(async () => {
|
|
224
224
|
let e = U.current;
|
|
@@ -227,7 +227,7 @@ function C(v = {}) {
|
|
|
227
227
|
try {
|
|
228
228
|
let r = await X().query({
|
|
229
229
|
context: t,
|
|
230
|
-
query:
|
|
230
|
+
query: u,
|
|
231
231
|
variables: {
|
|
232
232
|
filter: x(Y),
|
|
233
233
|
limit: 50,
|
|
@@ -236,62 +236,62 @@ function C(v = {}) {
|
|
|
236
236
|
fetchPolicy: "network-only"
|
|
237
237
|
});
|
|
238
238
|
if (e !== U.current || n !== G.current || !r.data?.notifications) return;
|
|
239
|
-
let { items: i, total:
|
|
240
|
-
if (
|
|
241
|
-
for (let e of
|
|
242
|
-
j(
|
|
243
|
-
} else U.current += 1, W.current = new Set(
|
|
244
|
-
z(
|
|
239
|
+
let { items: i, total: o, hasMore: s } = r.data.notifications, c = i.map(_), l = a(q.current, c, s, W.current);
|
|
240
|
+
if (l.continued) {
|
|
241
|
+
for (let e of c) W.current.add(e.id);
|
|
242
|
+
j(l.list);
|
|
243
|
+
} else U.current += 1, W.current = new Set(c.map((e) => e.id)), j(l.list), L(s);
|
|
244
|
+
R(o), z(Date.now());
|
|
245
245
|
} catch (e) {
|
|
246
246
|
console.error("[useNotifications] Failed to refresh notifications:", e);
|
|
247
247
|
}
|
|
248
|
-
}, [Y, X]),
|
|
248
|
+
}, [Y, X]), fe = f(async (e) => {
|
|
249
249
|
try {
|
|
250
250
|
await X().mutate({
|
|
251
251
|
context: t,
|
|
252
|
-
mutation:
|
|
252
|
+
mutation: te,
|
|
253
253
|
variables: { id: e }
|
|
254
254
|
}), j((t) => t.map((t) => t.id === e ? {
|
|
255
255
|
...t,
|
|
256
256
|
readAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
257
257
|
} : t)), O(Math.max(0, D - 1));
|
|
258
258
|
} catch (e) {
|
|
259
|
-
console.error("[useNotifications] Failed to mark as read:", e),
|
|
259
|
+
console.error("[useNotifications] Failed to mark as read:", e), F("Failed to mark notification as read");
|
|
260
260
|
}
|
|
261
261
|
}, [
|
|
262
262
|
X,
|
|
263
263
|
O,
|
|
264
264
|
D
|
|
265
|
-
]),
|
|
265
|
+
]), pe = f(async () => {
|
|
266
266
|
try {
|
|
267
267
|
await X().mutate({
|
|
268
268
|
context: t,
|
|
269
|
-
mutation:
|
|
269
|
+
mutation: ee
|
|
270
270
|
}), j((e) => e.map((e) => ({
|
|
271
271
|
...e,
|
|
272
272
|
readAt: e.readAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
273
273
|
}))), O(0);
|
|
274
274
|
} catch (e) {
|
|
275
|
-
console.error("[useNotifications] Failed to mark all as read:", e),
|
|
275
|
+
console.error("[useNotifications] Failed to mark all as read:", e), F("Failed to mark all notifications as read");
|
|
276
276
|
}
|
|
277
|
-
}, [X, O]),
|
|
277
|
+
}, [X, O]), me = f(async (e) => {
|
|
278
278
|
try {
|
|
279
279
|
await X().mutate({
|
|
280
280
|
context: t,
|
|
281
|
-
mutation:
|
|
281
|
+
mutation: s,
|
|
282
282
|
variables: { id: e }
|
|
283
283
|
}), j((t) => t.map((t) => t.id === e ? {
|
|
284
284
|
...t,
|
|
285
285
|
archivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
286
286
|
} : t));
|
|
287
287
|
} catch (e) {
|
|
288
|
-
console.error("[useNotifications] Failed to archive notification:", e),
|
|
288
|
+
console.error("[useNotifications] Failed to archive notification:", e), F("Failed to archive notification");
|
|
289
289
|
}
|
|
290
|
-
}, [X]),
|
|
290
|
+
}, [X]), he = f(async (e) => {
|
|
291
291
|
try {
|
|
292
292
|
await X().mutate({
|
|
293
293
|
context: t,
|
|
294
|
-
mutation:
|
|
294
|
+
mutation: c,
|
|
295
295
|
variables: { notificationIds: e }
|
|
296
296
|
});
|
|
297
297
|
let n = new Set(e);
|
|
@@ -300,26 +300,26 @@ function C(v = {}) {
|
|
|
300
300
|
archivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
301
301
|
} : e));
|
|
302
302
|
} catch (e) {
|
|
303
|
-
console.error("[useNotifications] Failed to bulk archive:", e),
|
|
303
|
+
console.error("[useNotifications] Failed to bulk archive:", e), F("Failed to archive notifications");
|
|
304
304
|
}
|
|
305
|
-
}, [X]),
|
|
305
|
+
}, [X]), ge = f(async (e) => {
|
|
306
306
|
try {
|
|
307
307
|
await X().mutate({
|
|
308
308
|
context: t,
|
|
309
|
-
mutation:
|
|
309
|
+
mutation: d,
|
|
310
310
|
variables: { id: e }
|
|
311
311
|
}), j((t) => t.map((t) => t.id === e ? {
|
|
312
312
|
...t,
|
|
313
313
|
archivedAt: void 0
|
|
314
314
|
} : t));
|
|
315
315
|
} catch (e) {
|
|
316
|
-
console.error("[useNotifications] Failed to unarchive notification:", e),
|
|
316
|
+
console.error("[useNotifications] Failed to unarchive notification:", e), F("Failed to restore notification");
|
|
317
317
|
}
|
|
318
|
-
}, [X]),
|
|
318
|
+
}, [X]), _e = f(async (e, n) => {
|
|
319
319
|
try {
|
|
320
320
|
await X().mutate({
|
|
321
321
|
context: t,
|
|
322
|
-
mutation:
|
|
322
|
+
mutation: re,
|
|
323
323
|
variables: { input: {
|
|
324
324
|
notificationId: e,
|
|
325
325
|
actionId: n
|
|
@@ -330,7 +330,7 @@ function C(v = {}) {
|
|
|
330
330
|
readAt: t.readAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
331
331
|
} : t));
|
|
332
332
|
} catch (e) {
|
|
333
|
-
console.error("[useNotifications] Failed to record notification action:", e),
|
|
333
|
+
console.error("[useNotifications] Failed to record notification action:", e), F("Failed to record notification action");
|
|
334
334
|
}
|
|
335
335
|
}, [X]);
|
|
336
336
|
return p(() => {
|
|
@@ -338,27 +338,27 @@ function C(v = {}) {
|
|
|
338
338
|
}, [Z]), p(() => {
|
|
339
339
|
Q();
|
|
340
340
|
}, [Q]), p(() => {
|
|
341
|
-
if (!
|
|
341
|
+
if (!S?.id) return;
|
|
342
342
|
let e = X(), t = e.subscribe({
|
|
343
|
-
query:
|
|
344
|
-
variables: { userId:
|
|
343
|
+
query: ne,
|
|
344
|
+
variables: { userId: S.id }
|
|
345
345
|
}).subscribe({
|
|
346
346
|
next: (e) => {
|
|
347
347
|
let t = e.data?.notificationReceived;
|
|
348
348
|
if (!t) return;
|
|
349
349
|
let n = _(t);
|
|
350
|
-
j((e) => [n, ...e.filter((e) => e.id !== n.id)]),
|
|
350
|
+
j((e) => [n, ...e.filter((e) => e.id !== n.id)]), z(Date.now()), C?.emit("notification:received", { notification: n });
|
|
351
351
|
},
|
|
352
352
|
error: (e) => {
|
|
353
353
|
console.error("[useNotifications] Notification subscription failed:", e);
|
|
354
354
|
}
|
|
355
355
|
}), n = e.subscribe({
|
|
356
356
|
query: ie,
|
|
357
|
-
variables: { userId:
|
|
357
|
+
variables: { userId: S.id }
|
|
358
358
|
}).subscribe({
|
|
359
359
|
next: (e) => {
|
|
360
360
|
let t = e.data?.unreadCountUpdated;
|
|
361
|
-
typeof t == "number" && (O(t),
|
|
361
|
+
typeof t == "number" && (O(t), C?.emit("notification:unread-count-updated", { unreadCount: t }));
|
|
362
362
|
},
|
|
363
363
|
error: (e) => {
|
|
364
364
|
console.error("[useNotifications] Unread count subscription failed:", e);
|
|
@@ -368,8 +368,8 @@ function C(v = {}) {
|
|
|
368
368
|
t.unsubscribe(), n.unsubscribe();
|
|
369
369
|
};
|
|
370
370
|
}, [
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
S?.id,
|
|
372
|
+
C,
|
|
373
373
|
X,
|
|
374
374
|
O
|
|
375
375
|
]), p(() => {
|
|
@@ -381,26 +381,27 @@ function C(v = {}) {
|
|
|
381
381
|
notifications: m(() => A.filter((e) => e.deliveryStatus === "UNSUBSCRIBED" || e.status === "ARCHIVED" && !e.archivedAt ? !1 : J.archived === !0 ? !!e.archivedAt : J.archived !== !1 || !e.archivedAt), [J.archived, A]),
|
|
382
382
|
allNotifications: A,
|
|
383
383
|
unreadCount: D,
|
|
384
|
-
selectedNotification:
|
|
384
|
+
selectedNotification: oe,
|
|
385
385
|
notificationFilter: J,
|
|
386
|
-
isLoading:
|
|
386
|
+
isLoading: M,
|
|
387
387
|
isLoadingMore: B,
|
|
388
|
-
error:
|
|
389
|
-
hasMore:
|
|
390
|
-
total:
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
388
|
+
error: P,
|
|
389
|
+
hasMore: I,
|
|
390
|
+
total: ce,
|
|
391
|
+
dataUpdatedAt: le,
|
|
392
|
+
markAsRead: fe,
|
|
393
|
+
markAllAsRead: pe,
|
|
394
|
+
archiveNotification: me,
|
|
395
|
+
bulkArchive: he,
|
|
396
|
+
unarchiveNotification: ge,
|
|
397
|
+
recordAction: _e,
|
|
398
|
+
setSelectedNotification: se,
|
|
399
|
+
updateFilter: T,
|
|
399
400
|
resetFilter: E,
|
|
400
401
|
refetch: Z,
|
|
401
|
-
loadMore:
|
|
402
|
+
loadMore: de
|
|
402
403
|
};
|
|
403
404
|
}
|
|
404
|
-
export { _ as mapBackendToMfeNotification,
|
|
405
|
+
export { _ as mapBackendToMfeNotification, S as useNotifications };
|
|
405
406
|
|
|
406
407
|
//# sourceMappingURL=useNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetMyUnreadNotificationCountDocument","NotificationOps.MarkNotificationAsReadDocument","NotificationOps.MarkAllMyNotificationsAsReadDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.ArchiveNotificationsDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.RecordNotificationActionDocument","NotificationOps.NotificationReceivedDocument","NotificationOps.UnreadCountUpdatedDocument","mapBackendToMfeNotification","n","mapNotificationType","mapPriority","action","item","mapStatus","t","p","s","buildBackendFilter","backend","filter","mergeNotificationFilter","baseFilter","useNotifications","useNotification","setStoreUnreadCount","useNotificationStore","notifications","setNotifications","useState","selectedNotification","setSelectedNotification","isLoading","setIsLoading","error","setError","hasMore","setHasMore","total","setTotal","isLoadingMore","setIsLoadingMore","loadingMoreRef","useRef","listGenerationRef","pagedIdsRef","refreshSeqRef","replacingListRef","notificationsRef","effectiveFilter","useMemo","notificationFilter","options","debouncedFilter","setDebouncedFilter","timeout","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","generation","setIsLoadingNotifications","result","USER_NOTIFICATION_CONTEXT","GetNotificationsDocument","mapped","notification","err","message","fetchUnreadCount","GetMyUnreadNotificationCountDocument","loadMore","pageWindow","nextNotificationWindow","more","appendNotificationPage","prev","refreshFirstPage","refresh","freshTotal","firstPageHasMore","firstPage","items","merged","mergeRefreshedFirstPage","handleMarkAsRead","MarkNotificationAsReadDocument","notificationId","unreadCount","handleMarkAllAsRead","MarkAllMyNotificationsAsReadDocument","handleArchive","ArchiveNotificationDocument","handleBulkArchive","ArchiveNotificationsDocument","idsSet","notificationIds","handleUnarchive","UnarchiveNotificationDocument","handleRecordAction","RecordNotificationActionDocument","useEffect","currentUser","client","notificationSubscription","NotificationReceivedDocument","eventBus","unreadSubscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","updateNotificationFilter","resetNotificationFilter"],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport {\n NOTIFICATION_PAGE_SIZE,\n appendNotificationPage,\n mergeRefreshedFirstPage,\n nextNotificationWindow,\n} from './notificationPaging';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\n NotificationFieldsFragment,\n NotificationReceivedSubscription,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\n\n// ---------------------------------------------------------------------------\n// GraphQL Operations — using generated Document nodes from global-operations\n// ---------------------------------------------------------------------------\n\n/**\n * Backend Notification item type derived from the generated query\n */\ntype BackendNotification = NotificationFieldsFragment;\n\ninterface UseNotificationsOptions {\n baseFilter?: Partial<NotificationFilter>;\n unreadFilter?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Mapping helpers — backend → MFE types\n// ---------------------------------------------------------------------------\n\n/** The GraphQL notification as the module's `Notification` (also used by the v2 detail panel). */\nexport function mapBackendToMfeNotification(n: BackendNotification): Notification {\n return {\n id: n.id,\n type: mapNotificationType(n.type),\n priority: mapPriority(n.priority),\n title: n.title,\n body: n.message,\n actionUrl: n.redirectUrl ?? undefined,\n actions: (n.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n appName: n.appName ?? undefined,\n archivedAt: n.archivedAt ?? undefined,\n channel: n.channel as Notification['channel'],\n clickedAt: n.clickedAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n deliveryStatus: n.deliveryStatus ?? undefined,\n htmlBody: n.htmlMessage ?? undefined,\n media: (n.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n openedAt: n.openedAt ?? undefined,\n recipientEmail: n.recipientEmail ?? undefined,\n recipientPhone: n.recipientPhone ?? undefined,\n scheduledFor: n.scheduledFor ?? undefined,\n scheduledNotification: n.scheduledNotification\n ? {\n id: n.scheduledNotification.id,\n scheduledFor: n.scheduledNotification.scheduledFor,\n status: n.scheduledNotification.status,\n timezone: n.scheduledNotification.timezone ?? undefined,\n }\n : undefined,\n sentAt: n.sentAt ?? undefined,\n status: mapStatus(n.status),\n readAt: n.readAt ?? undefined,\n createdAt: n.createdAt,\n channels: [\n {\n id: n.id,\n channel: n.channel as Notification['channel'],\n status: mapStatus(n.status),\n sentAt: n.sentAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n failedAt: n.failedAt ?? undefined,\n errorCode: n.errorCode ?? undefined,\n errorMessage: n.errorMessage ?? undefined,\n },\n ],\n metadata: n.metadata ?? undefined,\n topic: n.topic\n ? {\n id: n.topic.id,\n name: n.topic.name,\n slug: n.topic.slug,\n type: mapNotificationType(n.topic.type),\n }\n : undefined,\n topicId: n.topicId ?? undefined,\n };\n}\n\nfunction mapNotificationType(t: string) {\n const map: Record<string, Notification['type']> = {\n SYSTEM: 'SYSTEM',\n TRANSACTIONAL: 'TRANSACTIONAL',\n MARKETING: 'MARKETING',\n ALERT: 'ALERT',\n };\n return map[t] || 'SYSTEM';\n}\n\nfunction mapPriority(p: string) {\n const map: Record<string, Notification['priority']> = {\n LOW: 'LOW',\n MEDIUM: 'NORMAL',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n return map[p] || 'NORMAL';\n}\n\nfunction mapStatus(s: string) {\n const map: Record<string, Notification['status']> = {\n DRAFT: 'PENDING',\n PENDING: 'PENDING',\n SCHEDULED: 'PENDING',\n TRIGGERED: 'SENT',\n SENT: 'SENT',\n DELIVERED: 'DELIVERED',\n READ: 'DELIVERED',\n FAILED: 'FAILED',\n CANCELLED: 'ARCHIVED',\n EXPIRED: 'ARCHIVED',\n };\n return map[s] || 'PENDING';\n}\n\n// ---------------------------------------------------------------------------\n// Build the backend filter from the MFE NotificationFilter shape\n// ---------------------------------------------------------------------------\n\nfunction buildBackendFilter(filter: NotificationFilter) {\n const backend: Record<string, unknown> = {};\n\n // Type filter — map MFE type names to backend enum\n if (filter.type !== 'ALL') {\n const typeMap: Record<string, string> = {\n SYSTEM: 'SYSTEM',\n ACTIVITY: 'TRANSACTIONAL',\n BILLING: 'TRANSACTIONAL',\n SECURITY: 'ALERT',\n SOCIAL: 'MARKETING',\n REMINDER: 'SYSTEM',\n };\n backend.type = typeMap[filter.type] || filter.type;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL') {\n const prioMap: Record<string, string> = {\n LOW: 'LOW',\n NORMAL: 'MEDIUM',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n backend.priority = prioMap[filter.priority] || filter.priority;\n }\n\n // Read/unread filter — coerce null to undefined\n if (filter.isRead !== null && filter.isRead !== undefined) {\n backend.isRead = filter.isRead;\n }\n\n if (filter.topicId) {\n backend.topicId = filter.topicId;\n }\n\n if (filter.channel && filter.channel !== 'ALL') {\n backend.channel = filter.channel;\n }\n\n if (filter.archived !== null && filter.archived !== undefined) {\n backend.archived = filter.archived;\n }\n\n if (filter.search) {\n backend.search = filter.search;\n }\n\n // Date range\n if (filter.dateRange.start) {\n backend.startDate = filter.dateRange.start.toISOString();\n }\n if (filter.dateRange.end) {\n backend.endDate = filter.dateRange.end.toISOString();\n }\n\n return Object.keys(backend).length > 0 ? backend : undefined;\n}\n\nfunction mergeNotificationFilter(\n filter: NotificationFilter,\n baseFilter?: Partial<NotificationFilter>\n): NotificationFilter {\n if (!baseFilter) return filter;\n\n return {\n ...filter,\n ...baseFilter,\n dateRange: {\n ...filter.dateRange,\n ...(baseFilter.dateRange || {}),\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to manage notifications with real GraphQL backend integration.\n *\n * Uses the global Apollo client to query the notification service via the\n * public gateway (https://gw-global.local.burdenoff.com/global/graphql).\n *\n * @example\n * ```tsx\n * const { notifications, unreadCount, markAsRead } = useNotifications();\n * ```\n */\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { authToken, apiGatewayUrl, currentUser, eventBus } = useNotification();\n const {\n notificationFilter,\n updateNotificationFilter,\n resetNotificationFilter,\n unreadCount,\n setUnreadCount: setStoreUnreadCount,\n setIsLoadingNotifications,\n } = useNotificationStore();\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [hasMore, setHasMore] = useState(false);\n const [total, setTotal] = useState(0);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n // One \"load more\" at a time; the state drives the list's loading row.\n const loadingMoreRef = useRef(false);\n // Bumped whenever the list starts over (a new filter, a refetch), so a page\n // that was requested for the previous list is dropped instead of appended.\n const listGenerationRef = useRef(0);\n // Ids that came from the server's pages for the current list, as opposed to\n // the live feed; only these set where the next page starts.\n const pagedIdsRef = useRef<Set<string>>(new Set());\n // Each tab-refresh gets a number; only the latest one's answer is used.\n const refreshSeqRef = useRef(0);\n // A new first page (new filter, refetch) is on its way: the loaded list is\n // about to be replaced, so no page may be added after it meanwhile.\n const replacingListRef = useRef(false);\n // The loaded list as of the last render, for the tab-refresh merge below.\n const notificationsRef = useRef<Notification[]>([]);\n useEffect(() => {\n notificationsRef.current = notifications;\n }, [notifications]);\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\n const [debouncedFilter, setDebouncedFilter] = useState(effectiveFilter);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => setDebouncedFilter(effectiveFilter), 250);\n return () => window.clearTimeout(timeout);\n }, [effectiveFilter]);\n\n // Client accessor — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n // ---- Fetch notifications ------------------------------------------------\n\n const fetchNotifications = useCallback(async () => {\n listGenerationRef.current += 1;\n const generation = listGenerationRef.current;\n replacingListRef.current = true;\n setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications && generation === listGenerationRef.current) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n pagedIdsRef.current = new Set(mapped.map((notification) => notification.id));\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch notifications';\n console.error('[useNotifications] Failed to fetch notifications:', err);\n setError(message);\n // The list on screen was loaded for an earlier filter: do not page it.\n if (generation === listGenerationRef.current) setHasMore(false);\n } finally {\n if (generation === listGenerationRef.current) replacingListRef.current = false;\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [debouncedFilter, getClient, setIsLoadingNotifications]);\n\n // ---- Fetch unread count -------------------------------------------------\n\n const fetchUnreadCount = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: options.unreadFilter || { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n if (result.data) {\n setStoreUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to fetch unread count:', err);\n }\n }, [getClient, options.unreadFilter, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore || loadingMoreRef.current || replacingListRef.current) return;\n const pageWindow = nextNotificationWindow(notifications, pagedIdsRef.current, debouncedFilter);\n if (!pageWindow) return;\n loadingMoreRef.current = true;\n setIsLoadingMore(true);\n const generation = listGenerationRef.current;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n // Everything at or before the oldest loaded notification (the\n // filter's own end date is never earlier than that).\n filter: buildBackendFilter({\n ...debouncedFilter,\n dateRange: { ...debouncedFilter.dateRange, end: pageWindow.before },\n }),\n limit: pageWindow.limit,\n offset: pageWindow.offset,\n },\n fetchPolicy: 'network-only',\n });\n\n // The list started over (new filter or refetch) while this page loaded.\n if (generation !== listGenerationRef.current) return;\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n for (const notification of more) pagedIdsRef.current.add(notification.id);\n setNotifications((prev) => appendNotificationPage(prev, more));\n // `total` here counts only the window, so the list's total stays as\n // the first page reported it.\n setHasMore(result.data.notifications.hasMore);\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more notifications';\n console.error('[useNotifications] Failed to load more:', err);\n setError(message);\n } finally {\n loadingMoreRef.current = false;\n setIsLoadingMore(false);\n }\n }, [debouncedFilter, getClient, hasMore, notifications]);\n\n // Coming back to the tab: fetch the first page again for anything new, and\n // keep the older pages already scrolled through.\n const refreshFirstPage = useCallback(async () => {\n const generation = listGenerationRef.current;\n refreshSeqRef.current += 1;\n const refresh = refreshSeqRef.current;\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n // The list started over, or a later refresh superseded this one.\n if (\n generation !== listGenerationRef.current ||\n refresh !== refreshSeqRef.current ||\n !result.data?.notifications\n ) {\n return;\n }\n const { items, total: freshTotal, hasMore: firstPageHasMore } = result.data.notifications;\n const firstPage = items.map(mapBackendToMfeNotification);\n const merged = mergeRefreshedFirstPage(\n notificationsRef.current,\n firstPage,\n firstPageHasMore,\n pagedIdsRef.current\n );\n if (merged.continued) {\n // The older pages carry on after the fresh one: keep them, and\n // whether more exist is still what the last of them said.\n for (const notification of firstPage) pagedIdsRef.current.add(notification.id);\n setNotifications(merged.list);\n } else {\n // The list starts over from the fresh first page; a page still\n // loading belongs to the old list and is dropped when it arrives.\n listGenerationRef.current += 1;\n pagedIdsRef.current = new Set(firstPage.map((notification) => notification.id));\n setNotifications(merged.list);\n setHasMore(firstPageHasMore);\n }\n setTotal(freshTotal);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to refresh notifications:', err);\n }\n }, [debouncedFilter, getClient]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkNotificationAsReadDocument,\n variables: { id: notificationId },\n });\n // Optimistic: update local state\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, readAt: new Date().toISOString() } : n\n )\n );\n setStoreUnreadCount(Math.max(0, unreadCount - 1));\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark as read:', err);\n setError('Failed to mark notification as read');\n }\n },\n [getClient, setStoreUnreadCount, unreadCount]\n );\n\n const handleMarkAllAsRead = useCallback(async () => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument,\n });\n // Optimistic: update all local\n setNotifications((prev) =>\n prev.map((n) => ({ ...n, readAt: n.readAt || new Date().toISOString() }))\n );\n setStoreUnreadCount(0);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark all as read:', err);\n setError('Failed to mark all notifications as read');\n }\n }, [getClient, setStoreUnreadCount]);\n\n const handleArchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, archivedAt: new Date().toISOString() } : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to archive notification:', err);\n setError('Failed to archive notification');\n }\n },\n [getClient]\n );\n\n const handleBulkArchive = useCallback(\n async (notificationIds: string[]) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationsDocument,\n variables: { notificationIds },\n });\n const idsSet = new Set(notificationIds);\n setNotifications((prev) =>\n prev.map((n) => (idsSet.has(n.id) ? { ...n, archivedAt: new Date().toISOString() } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to bulk archive:', err);\n setError('Failed to archive notifications');\n }\n },\n [getClient]\n );\n\n const handleUnarchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, archivedAt: undefined } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to unarchive notification:', err);\n setError('Failed to restore notification');\n }\n },\n [getClient]\n );\n\n const handleRecordAction = useCallback(\n async (notificationId: string, actionId?: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.RecordNotificationActionDocument,\n variables: { input: { notificationId, actionId } },\n });\n\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId\n ? {\n ...n,\n clickedAt: new Date().toISOString(),\n readAt: n.readAt || new Date().toISOString(),\n }\n : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to record notification action:', err);\n setError('Failed to record notification action');\n }\n },\n [getClient]\n );\n\n // ---- Initial fetch on mount + when filter changes -----------------------\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n fetchUnreadCount();\n }, [fetchUnreadCount]);\n\n // ---- Live notification subscriptions ------------------------------------\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getClient();\n const notificationSubscription = client\n .subscribe<NotificationReceivedSubscription>({\n query: NotificationOps.NotificationReceivedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const notification = result.data?.notificationReceived;\n if (!notification) return;\n const mapped = mapBackendToMfeNotification(notification);\n setNotifications((prev) => [mapped, ...prev.filter((item) => item.id !== mapped.id)]);\n eventBus?.emit('notification:received', { notification: mapped });\n },\n error: (err) => {\n console.error('[useNotifications] Notification subscription failed:', err);\n },\n });\n\n const unreadSubscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: NotificationOps.UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setStoreUnreadCount(nextCount);\n eventBus?.emit('notification:unread-count-updated', { unreadCount: nextCount });\n }\n },\n error: (err) => {\n console.error('[useNotifications] Unread count subscription failed:', err);\n },\n });\n\n return () => {\n notificationSubscription.unsubscribe();\n unreadSubscription.unsubscribe();\n };\n }, [currentUser?.id, eventBus, getClient, setStoreUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n void refreshFirstPage();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshFirstPage, fetchUnreadCount]);\n\n const visibleNotifications = useMemo(\n () =>\n notifications.filter((notification) => {\n if (notification.deliveryStatus === 'UNSUBSCRIBED') {\n return false;\n }\n\n if (notification.status === 'ARCHIVED' && !notification.archivedAt) {\n return false;\n }\n\n if (effectiveFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (effectiveFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n }),\n [effectiveFilter.archived, notifications]\n );\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\n /** A further page is loading (infinite scroll). */\n isLoadingMore,\n error,\n hasMore,\n total,\n markAsRead: handleMarkAsRead,\n markAllAsRead: handleMarkAllAsRead,\n archiveNotification: handleArchive,\n bulkArchive: handleBulkArchive,\n unarchiveNotification: handleUnarchive,\n recordAction: handleRecordAction,\n setSelectedNotification,\n updateFilter: updateNotificationFilter,\n resetFilter: resetNotificationFilter,\n refetch: fetchNotifications,\n loadMore,\n };\n}\n"],"mappings":";;;;;;;AAuCA,SAAgBU,EAA4B,GAAsC;CAChF,OAAO;EACL,IAAIC,EAAE;EACN,MAAMC,EAAoBD,EAAE,IAAI;EAChC,UAAUE,EAAYF,EAAE,QAAQ;EAChC,OAAOA,EAAE;EACT,MAAMA,EAAE;EACR,WAAWA,EAAE,eAAe,KAAA;EAC5B,UAAUA,EAAE,WAAW,CAAC,EAAA,CAAG,KAAK,OAAY;GAC1C,IAAIG,EAAO;GACX,OAAOA,EAAO;GACd,KAAKA,EAAO;GACZ,OAAOA,EAAO,SAAS,KAAA;GACvB,YAAYA,EAAO,cAAc,KAAA;GACjC,UAAUA,EAAO,YAAY,KAAA;EAC/B,EAAE;EACF,SAASH,EAAE,WAAW,KAAA;EACtB,YAAYA,EAAE,cAAc,KAAA;EAC5B,SAASA,EAAE;EACX,WAAWA,EAAE,aAAa,KAAA;EAC1B,aAAaA,EAAE,eAAe,KAAA;EAC9B,gBAAgBA,EAAE,kB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,KAGLnB,EAAgB,aAAa,KACxB,EAAQmB,EAAa,aAG1BnB,EAAgB,aAAa,MACxB,CAACmB,EAAa,UAIxB,GACH,CAACnB,EAAgB,UAAUtB,CAAa,CAIzB;EACf,kBAAkBA;EAClB;EACA;EACA,oBAAoBsB;EACpB;EAEA;EACA;EACA;EACA;EACA,YAAYsC;EACZ,eAAeI;EACf,qBAAqBE;EACrB,aAAaE;EACb,uBAAuBI;EACvB,cAAcE;EACd;EACA,cAAcY;EACd,aAAaC;EACb,SAASrD;EACT;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useNotifications.js","names":["NotificationOps.GetNotificationsDocument","NotificationOps.GetMyUnreadNotificationCountDocument","NotificationOps.MarkNotificationAsReadDocument","NotificationOps.MarkAllMyNotificationsAsReadDocument","NotificationOps.ArchiveNotificationDocument","NotificationOps.ArchiveNotificationsDocument","NotificationOps.UnarchiveNotificationDocument","NotificationOps.RecordNotificationActionDocument","NotificationOps.NotificationReceivedDocument","NotificationOps.UnreadCountUpdatedDocument","mapBackendToMfeNotification","n","mapNotificationType","mapPriority","action","item","mapStatus","t","p","s","buildBackendFilter","backend","filter","mergeNotificationFilter","baseFilter","useNotifications","useNotification","setStoreUnreadCount","useNotificationStore","notifications","setNotifications","useState","selectedNotification","setSelectedNotification","isLoading","setIsLoading","error","setError","hasMore","setHasMore","total","setTotal","dataUpdatedAt","setDataUpdatedAt","isLoadingMore","setIsLoadingMore","loadingMoreRef","useRef","listGenerationRef","pagedIdsRef","refreshSeqRef","replacingListRef","notificationsRef","effectiveFilter","useMemo","notificationFilter","options","debouncedFilter","setDebouncedFilter","timeout","getClient","useCallback","getGlobalNotificationClient","apiGatewayUrl","authToken","fetchNotifications","generation","setIsLoadingNotifications","result","USER_NOTIFICATION_CONTEXT","GetNotificationsDocument","mapped","notification","err","message","fetchUnreadCount","GetMyUnreadNotificationCountDocument","loadMore","pageWindow","nextNotificationWindow","more","appendNotificationPage","prev","refreshFirstPage","refresh","freshTotal","firstPageHasMore","firstPage","items","merged","mergeRefreshedFirstPage","handleMarkAsRead","MarkNotificationAsReadDocument","notificationId","unreadCount","handleMarkAllAsRead","MarkAllMyNotificationsAsReadDocument","handleArchive","ArchiveNotificationDocument","handleBulkArchive","ArchiveNotificationsDocument","idsSet","notificationIds","handleUnarchive","UnarchiveNotificationDocument","handleRecordAction","RecordNotificationActionDocument","useEffect","currentUser","client","notificationSubscription","NotificationReceivedDocument","eventBus","unreadSubscription","UnreadCountUpdatedDocument","nextCount","handleVisibilityChange","updateNotificationFilter","resetNotificationFilter"],"sources":["../../src/hooks/useNotifications.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { getGlobalNotificationClient, USER_NOTIFICATION_CONTEXT } from '../graphql/global-client';\nimport { useNotificationStore } from '../store/notificationStore';\nimport type { Notification, NotificationFilter } from '../types';\nimport {\n NOTIFICATION_PAGE_SIZE,\n appendNotificationPage,\n mergeRefreshedFirstPage,\n nextNotificationWindow,\n} from './notificationPaging';\nimport * as NotificationOps from '../generated/global-operations';\nimport type {\n GetNotificationsQuery,\n GetMyUnreadNotificationCountQuery,\n NotificationFieldsFragment,\n NotificationReceivedSubscription,\n UnreadCountUpdatedSubscription,\n} from '../generated/global-operations';\n\n// ---------------------------------------------------------------------------\n// GraphQL Operations — using generated Document nodes from global-operations\n// ---------------------------------------------------------------------------\n\n/**\n * Backend Notification item type derived from the generated query\n */\ntype BackendNotification = NotificationFieldsFragment;\n\ninterface UseNotificationsOptions {\n baseFilter?: Partial<NotificationFilter>;\n unreadFilter?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Mapping helpers — backend → MFE types\n// ---------------------------------------------------------------------------\n\n/** The GraphQL notification as the module's `Notification` (also used by the v2 detail panel). */\nexport function mapBackendToMfeNotification(n: BackendNotification): Notification {\n return {\n id: n.id,\n type: mapNotificationType(n.type),\n priority: mapPriority(n.priority),\n title: n.title,\n body: n.message,\n actionUrl: n.redirectUrl ?? undefined,\n actions: (n.actions || []).map((action) => ({\n id: action.id,\n label: action.label,\n url: action.url,\n style: action.style ?? undefined,\n actionType: action.actionType ?? undefined,\n metadata: action.metadata ?? undefined,\n })),\n appName: n.appName ?? undefined,\n archivedAt: n.archivedAt ?? undefined,\n channel: n.channel as Notification['channel'],\n clickedAt: n.clickedAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n deliveryStatus: n.deliveryStatus ?? undefined,\n htmlBody: n.htmlMessage ?? undefined,\n media: (n.media || []).map((item) => ({\n url: item.url,\n label: item.label ?? undefined,\n kind: item.kind ?? undefined,\n contentType: item.contentType ?? undefined,\n thumbnailUrl: item.thumbnailUrl ?? undefined,\n })),\n openedAt: n.openedAt ?? undefined,\n recipientEmail: n.recipientEmail ?? undefined,\n recipientPhone: n.recipientPhone ?? undefined,\n scheduledFor: n.scheduledFor ?? undefined,\n scheduledNotification: n.scheduledNotification\n ? {\n id: n.scheduledNotification.id,\n scheduledFor: n.scheduledNotification.scheduledFor,\n status: n.scheduledNotification.status,\n timezone: n.scheduledNotification.timezone ?? undefined,\n }\n : undefined,\n sentAt: n.sentAt ?? undefined,\n status: mapStatus(n.status),\n readAt: n.readAt ?? undefined,\n createdAt: n.createdAt,\n channels: [\n {\n id: n.id,\n channel: n.channel as Notification['channel'],\n status: mapStatus(n.status),\n sentAt: n.sentAt ?? undefined,\n deliveredAt: n.deliveredAt ?? undefined,\n failedAt: n.failedAt ?? undefined,\n errorCode: n.errorCode ?? undefined,\n errorMessage: n.errorMessage ?? undefined,\n },\n ],\n metadata: n.metadata ?? undefined,\n topic: n.topic\n ? {\n id: n.topic.id,\n name: n.topic.name,\n slug: n.topic.slug,\n type: mapNotificationType(n.topic.type),\n }\n : undefined,\n topicId: n.topicId ?? undefined,\n };\n}\n\nfunction mapNotificationType(t: string) {\n const map: Record<string, Notification['type']> = {\n SYSTEM: 'SYSTEM',\n TRANSACTIONAL: 'TRANSACTIONAL',\n MARKETING: 'MARKETING',\n ALERT: 'ALERT',\n };\n return map[t] || 'SYSTEM';\n}\n\nfunction mapPriority(p: string) {\n const map: Record<string, Notification['priority']> = {\n LOW: 'LOW',\n MEDIUM: 'NORMAL',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n return map[p] || 'NORMAL';\n}\n\nfunction mapStatus(s: string) {\n const map: Record<string, Notification['status']> = {\n DRAFT: 'PENDING',\n PENDING: 'PENDING',\n SCHEDULED: 'PENDING',\n TRIGGERED: 'SENT',\n SENT: 'SENT',\n DELIVERED: 'DELIVERED',\n READ: 'DELIVERED',\n FAILED: 'FAILED',\n CANCELLED: 'ARCHIVED',\n EXPIRED: 'ARCHIVED',\n };\n return map[s] || 'PENDING';\n}\n\n// ---------------------------------------------------------------------------\n// Build the backend filter from the MFE NotificationFilter shape\n// ---------------------------------------------------------------------------\n\nfunction buildBackendFilter(filter: NotificationFilter) {\n const backend: Record<string, unknown> = {};\n\n // Type filter — map MFE type names to backend enum\n if (filter.type !== 'ALL') {\n const typeMap: Record<string, string> = {\n SYSTEM: 'SYSTEM',\n ACTIVITY: 'TRANSACTIONAL',\n BILLING: 'TRANSACTIONAL',\n SECURITY: 'ALERT',\n SOCIAL: 'MARKETING',\n REMINDER: 'SYSTEM',\n };\n backend.type = typeMap[filter.type] || filter.type;\n }\n\n // Priority filter\n if (filter.priority !== 'ALL') {\n const prioMap: Record<string, string> = {\n LOW: 'LOW',\n NORMAL: 'MEDIUM',\n HIGH: 'HIGH',\n URGENT: 'URGENT',\n };\n backend.priority = prioMap[filter.priority] || filter.priority;\n }\n\n // Read/unread filter — coerce null to undefined\n if (filter.isRead !== null && filter.isRead !== undefined) {\n backend.isRead = filter.isRead;\n }\n\n if (filter.topicId) {\n backend.topicId = filter.topicId;\n }\n\n if (filter.channel && filter.channel !== 'ALL') {\n backend.channel = filter.channel;\n }\n\n if (filter.archived !== null && filter.archived !== undefined) {\n backend.archived = filter.archived;\n }\n\n if (filter.search) {\n backend.search = filter.search;\n }\n\n // Date range\n if (filter.dateRange.start) {\n backend.startDate = filter.dateRange.start.toISOString();\n }\n if (filter.dateRange.end) {\n backend.endDate = filter.dateRange.end.toISOString();\n }\n\n return Object.keys(backend).length > 0 ? backend : undefined;\n}\n\nfunction mergeNotificationFilter(\n filter: NotificationFilter,\n baseFilter?: Partial<NotificationFilter>\n): NotificationFilter {\n if (!baseFilter) return filter;\n\n return {\n ...filter,\n ...baseFilter,\n dateRange: {\n ...filter.dateRange,\n ...(baseFilter.dateRange || {}),\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to manage notifications with real GraphQL backend integration.\n *\n * Uses the global Apollo client to query the notification service via the\n * public gateway (https://gw-global.local.burdenoff.com/global/graphql).\n *\n * @example\n * ```tsx\n * const { notifications, unreadCount, markAsRead } = useNotifications();\n * ```\n */\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { authToken, apiGatewayUrl, currentUser, eventBus } = useNotification();\n const {\n notificationFilter,\n updateNotificationFilter,\n resetNotificationFilter,\n unreadCount,\n setUnreadCount: setStoreUnreadCount,\n setIsLoadingNotifications,\n } = useNotificationStore();\n\n const [notifications, setNotifications] = useState<Notification[]>([]);\n const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [hasMore, setHasMore] = useState(false);\n const [total, setTotal] = useState(0);\n // When the notifications on hand arrived (ms since the epoch), as React Query's `dataUpdatedAt`.\n const [dataUpdatedAt, setDataUpdatedAt] = useState(0);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n // One \"load more\" at a time; the state drives the list's loading row.\n const loadingMoreRef = useRef(false);\n // Bumped whenever the list starts over (a new filter, a refetch), so a page\n // that was requested for the previous list is dropped instead of appended.\n const listGenerationRef = useRef(0);\n // Ids that came from the server's pages for the current list, as opposed to\n // the live feed; only these set where the next page starts.\n const pagedIdsRef = useRef<Set<string>>(new Set());\n // Each tab-refresh gets a number; only the latest one's answer is used.\n const refreshSeqRef = useRef(0);\n // A new first page (new filter, refetch) is on its way: the loaded list is\n // about to be replaced, so no page may be added after it meanwhile.\n const replacingListRef = useRef(false);\n // The loaded list as of the last render, for the tab-refresh merge below.\n const notificationsRef = useRef<Notification[]>([]);\n useEffect(() => {\n notificationsRef.current = notifications;\n }, [notifications]);\n const effectiveFilter = useMemo(\n () => mergeNotificationFilter(notificationFilter, options.baseFilter),\n [notificationFilter, options.baseFilter]\n );\n const [debouncedFilter, setDebouncedFilter] = useState(effectiveFilter);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => setDebouncedFilter(effectiveFilter), 250);\n return () => window.clearTimeout(timeout);\n }, [effectiveFilter]);\n\n // Client accessor — coerce null/undefined authToken to undefined\n const getClient = useCallback(() => {\n return getGlobalNotificationClient(apiGatewayUrl ?? undefined, authToken ?? undefined);\n }, [apiGatewayUrl, authToken]);\n\n // ---- Fetch notifications ------------------------------------------------\n\n const fetchNotifications = useCallback(async () => {\n listGenerationRef.current += 1;\n const generation = listGenerationRef.current;\n replacingListRef.current = true;\n setIsLoading(true);\n setIsLoadingNotifications(true);\n setError(null);\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n\n if (result.data?.notifications && generation === listGenerationRef.current) {\n const mapped = result.data.notifications.items.map(mapBackendToMfeNotification);\n pagedIdsRef.current = new Set(mapped.map((notification) => notification.id));\n setNotifications(mapped);\n setTotal(result.data.notifications.total);\n setHasMore(result.data.notifications.hasMore);\n setDataUpdatedAt(Date.now());\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to fetch notifications';\n console.error('[useNotifications] Failed to fetch notifications:', err);\n setError(message);\n // The list on screen was loaded for an earlier filter: do not page it.\n if (generation === listGenerationRef.current) setHasMore(false);\n } finally {\n if (generation === listGenerationRef.current) replacingListRef.current = false;\n setIsLoading(false);\n setIsLoadingNotifications(false);\n }\n }, [debouncedFilter, getClient, setIsLoadingNotifications]);\n\n // ---- Fetch unread count -------------------------------------------------\n\n const fetchUnreadCount = useCallback(async () => {\n try {\n const client = getClient();\n const result = await client.query<GetMyUnreadNotificationCountQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetMyUnreadNotificationCountDocument,\n variables: { filter: options.unreadFilter || { channel: 'IN_APP' } },\n fetchPolicy: 'network-only',\n });\n if (result.data) {\n setStoreUnreadCount(result.data.myUnreadNotificationCount);\n }\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to fetch unread count:', err);\n }\n }, [getClient, options.unreadFilter, setStoreUnreadCount]);\n\n // ---- Load more ----------------------------------------------------------\n\n const loadMore = useCallback(async () => {\n if (!hasMore || loadingMoreRef.current || replacingListRef.current) return;\n const pageWindow = nextNotificationWindow(notifications, pagedIdsRef.current, debouncedFilter);\n if (!pageWindow) return;\n loadingMoreRef.current = true;\n setIsLoadingMore(true);\n const generation = listGenerationRef.current;\n\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n // Everything at or before the oldest loaded notification (the\n // filter's own end date is never earlier than that).\n filter: buildBackendFilter({\n ...debouncedFilter,\n dateRange: { ...debouncedFilter.dateRange, end: pageWindow.before },\n }),\n limit: pageWindow.limit,\n offset: pageWindow.offset,\n },\n fetchPolicy: 'network-only',\n });\n\n // The list started over (new filter or refetch) while this page loaded.\n if (generation !== listGenerationRef.current) return;\n if (result.data?.notifications) {\n const more = result.data.notifications.items.map(mapBackendToMfeNotification);\n for (const notification of more) pagedIdsRef.current.add(notification.id);\n setNotifications((prev) => appendNotificationPage(prev, more));\n // `total` here counts only the window, so the list's total stays as\n // the first page reported it.\n setHasMore(result.data.notifications.hasMore);\n setDataUpdatedAt(Date.now());\n }\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Failed to load more notifications';\n console.error('[useNotifications] Failed to load more:', err);\n setError(message);\n } finally {\n loadingMoreRef.current = false;\n setIsLoadingMore(false);\n }\n }, [debouncedFilter, getClient, hasMore, notifications]);\n\n // Coming back to the tab: fetch the first page again for anything new, and\n // keep the older pages already scrolled through.\n const refreshFirstPage = useCallback(async () => {\n const generation = listGenerationRef.current;\n refreshSeqRef.current += 1;\n const refresh = refreshSeqRef.current;\n try {\n const client = getClient();\n const result = await client.query<GetNotificationsQuery>({\n context: USER_NOTIFICATION_CONTEXT,\n query: NotificationOps.GetNotificationsDocument,\n variables: {\n filter: buildBackendFilter(debouncedFilter),\n limit: NOTIFICATION_PAGE_SIZE,\n offset: 0,\n },\n fetchPolicy: 'network-only',\n });\n // The list started over, or a later refresh superseded this one.\n if (\n generation !== listGenerationRef.current ||\n refresh !== refreshSeqRef.current ||\n !result.data?.notifications\n ) {\n return;\n }\n const { items, total: freshTotal, hasMore: firstPageHasMore } = result.data.notifications;\n const firstPage = items.map(mapBackendToMfeNotification);\n const merged = mergeRefreshedFirstPage(\n notificationsRef.current,\n firstPage,\n firstPageHasMore,\n pagedIdsRef.current\n );\n if (merged.continued) {\n // The older pages carry on after the fresh one: keep them, and\n // whether more exist is still what the last of them said.\n for (const notification of firstPage) pagedIdsRef.current.add(notification.id);\n setNotifications(merged.list);\n } else {\n // The list starts over from the fresh first page; a page still\n // loading belongs to the old list and is dropped when it arrives.\n listGenerationRef.current += 1;\n pagedIdsRef.current = new Set(firstPage.map((notification) => notification.id));\n setNotifications(merged.list);\n setHasMore(firstPageHasMore);\n }\n setTotal(freshTotal);\n setDataUpdatedAt(Date.now());\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to refresh notifications:', err);\n }\n }, [debouncedFilter, getClient]);\n\n // ---- Mutations ----------------------------------------------------------\n\n const handleMarkAsRead = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkNotificationAsReadDocument,\n variables: { id: notificationId },\n });\n // Optimistic: update local state\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, readAt: new Date().toISOString() } : n\n )\n );\n setStoreUnreadCount(Math.max(0, unreadCount - 1));\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark as read:', err);\n setError('Failed to mark notification as read');\n }\n },\n [getClient, setStoreUnreadCount, unreadCount]\n );\n\n const handleMarkAllAsRead = useCallback(async () => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.MarkAllMyNotificationsAsReadDocument,\n });\n // Optimistic: update all local\n setNotifications((prev) =>\n prev.map((n) => ({ ...n, readAt: n.readAt || new Date().toISOString() }))\n );\n setStoreUnreadCount(0);\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to mark all as read:', err);\n setError('Failed to mark all notifications as read');\n }\n }, [getClient, setStoreUnreadCount]);\n\n const handleArchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationDocument,\n variables: { id: notificationId },\n });\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId ? { ...n, archivedAt: new Date().toISOString() } : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to archive notification:', err);\n setError('Failed to archive notification');\n }\n },\n [getClient]\n );\n\n const handleBulkArchive = useCallback(\n async (notificationIds: string[]) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.ArchiveNotificationsDocument,\n variables: { notificationIds },\n });\n const idsSet = new Set(notificationIds);\n setNotifications((prev) =>\n prev.map((n) => (idsSet.has(n.id) ? { ...n, archivedAt: new Date().toISOString() } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to bulk archive:', err);\n setError('Failed to archive notifications');\n }\n },\n [getClient]\n );\n\n const handleUnarchive = useCallback(\n async (notificationId: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.UnarchiveNotificationDocument,\n variables: { id: notificationId },\n });\n\n setNotifications((prev) =>\n prev.map((n) => (n.id === notificationId ? { ...n, archivedAt: undefined } : n))\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to unarchive notification:', err);\n setError('Failed to restore notification');\n }\n },\n [getClient]\n );\n\n const handleRecordAction = useCallback(\n async (notificationId: string, actionId?: string) => {\n try {\n const client = getClient();\n await client.mutate({\n context: USER_NOTIFICATION_CONTEXT,\n mutation: NotificationOps.RecordNotificationActionDocument,\n variables: { input: { notificationId, actionId } },\n });\n\n setNotifications((prev) =>\n prev.map((n) =>\n n.id === notificationId\n ? {\n ...n,\n clickedAt: new Date().toISOString(),\n readAt: n.readAt || new Date().toISOString(),\n }\n : n\n )\n );\n } catch (err: unknown) {\n console.error('[useNotifications] Failed to record notification action:', err);\n setError('Failed to record notification action');\n }\n },\n [getClient]\n );\n\n // ---- Initial fetch on mount + when filter changes -----------------------\n\n useEffect(() => {\n fetchNotifications();\n }, [fetchNotifications]);\n\n useEffect(() => {\n fetchUnreadCount();\n }, [fetchUnreadCount]);\n\n // ---- Live notification subscriptions ------------------------------------\n\n useEffect(() => {\n if (!currentUser?.id) return undefined;\n\n const client = getClient();\n const notificationSubscription = client\n .subscribe<NotificationReceivedSubscription>({\n query: NotificationOps.NotificationReceivedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const notification = result.data?.notificationReceived;\n if (!notification) return;\n const mapped = mapBackendToMfeNotification(notification);\n setNotifications((prev) => [mapped, ...prev.filter((item) => item.id !== mapped.id)]);\n // The live feed keeps the list current: it is as of now.\n setDataUpdatedAt(Date.now());\n eventBus?.emit('notification:received', { notification: mapped });\n },\n error: (err) => {\n console.error('[useNotifications] Notification subscription failed:', err);\n },\n });\n\n const unreadSubscription = client\n .subscribe<UnreadCountUpdatedSubscription>({\n query: NotificationOps.UnreadCountUpdatedDocument,\n variables: { userId: currentUser.id },\n })\n .subscribe({\n next: (result) => {\n const nextCount = result.data?.unreadCountUpdated;\n if (typeof nextCount === 'number') {\n setStoreUnreadCount(nextCount);\n eventBus?.emit('notification:unread-count-updated', { unreadCount: nextCount });\n }\n },\n error: (err) => {\n console.error('[useNotifications] Unread count subscription failed:', err);\n },\n });\n\n return () => {\n notificationSubscription.unsubscribe();\n unreadSubscription.unsubscribe();\n };\n }, [currentUser?.id, eventBus, getClient, setStoreUnreadCount]);\n\n useEffect(() => {\n const handleVisibilityChange = () => {\n if (document.visibilityState === 'visible') {\n void refreshFirstPage();\n fetchUnreadCount();\n }\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n return () => document.removeEventListener('visibilitychange', handleVisibilityChange);\n }, [refreshFirstPage, fetchUnreadCount]);\n\n const visibleNotifications = useMemo(\n () =>\n notifications.filter((notification) => {\n if (notification.deliveryStatus === 'UNSUBSCRIBED') {\n return false;\n }\n\n if (notification.status === 'ARCHIVED' && !notification.archivedAt) {\n return false;\n }\n\n if (effectiveFilter.archived === true) {\n return Boolean(notification.archivedAt);\n }\n\n if (effectiveFilter.archived === false) {\n return !notification.archivedAt;\n }\n\n return true;\n }),\n [effectiveFilter.archived, notifications]\n );\n\n return {\n notifications: visibleNotifications,\n allNotifications: notifications,\n unreadCount,\n selectedNotification,\n notificationFilter: effectiveFilter,\n isLoading,\n /** A further page is loading (infinite scroll). */\n isLoadingMore,\n error,\n hasMore,\n total,\n /** When the notifications on hand arrived (ms since the epoch); 0 before the first answer. */\n dataUpdatedAt,\n markAsRead: handleMarkAsRead,\n markAllAsRead: handleMarkAllAsRead,\n archiveNotification: handleArchive,\n bulkArchive: handleBulkArchive,\n unarchiveNotification: handleUnarchive,\n recordAction: handleRecordAction,\n setSelectedNotification,\n updateFilter: updateNotificationFilter,\n resetFilter: resetNotificationFilter,\n refetch: fetchNotifications,\n loadMore,\n };\n}\n"],"mappings":";;;;;;;AAuCA,SAAgBU,EAA4B,GAAsC;CAChF,OAAO;EACL,IAAIC,EAAE;EACN,MAAMC,EAAoBD,EAAE,IAAI;EAChC,UAAUE,EAAYF,EAAE,QAAQ;EAChC,OAAOA,EAAE;EACT,MAAMA,EAAE;EACR,WAAWA,EAAE,eAAe,KAAA;EAC5B,UAAUA,EAAE,WAAW,CAAC,EAAA,CAAG,KAAK,OAAY;GAC1C,IAAIG,EAAO;GACX,OAAOA,EAAO;GACd,KAAKA,EAAO;GACZ,OAAOA,EAAO,SAAS,KAAA;GACvB,YAAYA,EAAO,cAAc,KAAA;GACjC,UAAUA,EAAO,YAAY,KAAA;EAC/B,EAAE;EACF,SAASH,EAAE,WAAW,KAAA;EACtB,YAAYA,EAAE,cAAc,KAAA;EAC5B,SAASA,EAAE;EACX,WAAWA,EAAE,aAAa,KAAA;EAC1B,aAAaA,EAAE,eAAe,KAAA;EAC9B,gBAAgBA,EAAE,kBAAkB,KAAA;EACpC,UAAUA,EAAE,eAAe,KAAA;EAC3B,QAAQA,EAAE,SAAS,CAAC,EAAA,CAAG,KAAK,OAAU;GACpC,KAAKI,EAAK;GACV,OAAOA,EAAK,SAAS,KAAA;GACrB,MAAMA,EAAK,QAAQ,KAAA;GACnB,aAAaA,EAAK,eAAe,KAAA;GACjC,cAAcA,EAAK,gBAAgB,KAAA;EACrC,EAAE;EACF,UAAUJ,EAAE,YAAY,KAAA;EACxB,gBAAgBA,EAAE,kBAAkB,KAAA;EACpC,gBAAgBA,EAAE,kBAAkB,KAAA;EACpC,cAAcA,EAAE,gBAAgB,KAAA;EAChC,uBAAuBA,EAAE,wBACrB;GACE,IAAIA,EAAE,sBAAsB;GAC5B,cAAcA,EAAE,sBAAsB;GACtC,QAAQA,EAAE,sBAAsB;GAChC,UAAUA,EAAE,sBAAsB,YAAY,KAAA;EA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F"}
|
|
@@ -20,6 +20,8 @@ export declare function preferenceKey(input: PreferenceTarget): string;
|
|
|
20
20
|
export declare function usePreferenceToggles(): {
|
|
21
21
|
preferencesByKey: Map<string, import('../types').NotificationPreference>;
|
|
22
22
|
preferencesLoading: boolean;
|
|
23
|
+
/** When the preferences arrived (ms since the epoch); 0 before. */
|
|
24
|
+
preferencesUpdatedAt: number;
|
|
23
25
|
savingKey: string | null;
|
|
24
26
|
saveFeedback: PreferenceFeedback | null;
|
|
25
27
|
togglePreference: (input: PreferenceTarget) => Promise<void>;
|
|
@@ -8,72 +8,73 @@ function c(e) {
|
|
|
8
8
|
return e.scope === "CHANNEL" ? `CHANNEL:${e.channel || ""}` : e.scope === "TYPE" ? `TYPE:${e.type || ""}` : e.scope === "TOPIC" ? `TOPIC:${e.topicId || ""}` : "GLOBAL";
|
|
9
9
|
}
|
|
10
10
|
function l() {
|
|
11
|
-
let l = n(), { preferencesByKey: u, isLoading: d,
|
|
11
|
+
let l = n(), { preferencesByKey: u, isLoading: d, dataUpdatedAt: f, setPreference: p, deletePreference: m } = e(), { trackPreferenceUpdated: h } = t(), [g, _] = s(null), [v, y] = s(null), b = o(null);
|
|
12
12
|
a(() => () => {
|
|
13
|
-
|
|
13
|
+
b.current && clearTimeout(b.current);
|
|
14
14
|
}, []);
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
let x = (e) => {
|
|
16
|
+
b.current && clearTimeout(b.current), y(e), b.current = setTimeout(() => {
|
|
17
|
+
y((t) => t?.key === e.key ? null : t), b.current = null;
|
|
18
18
|
}, 2500);
|
|
19
19
|
};
|
|
20
20
|
return {
|
|
21
21
|
preferencesByKey: u,
|
|
22
22
|
preferencesLoading: d,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
preferencesUpdatedAt: f,
|
|
24
|
+
savingKey: g,
|
|
25
|
+
saveFeedback: v,
|
|
25
26
|
togglePreference: async (e) => {
|
|
26
27
|
let t = c(e), n = u.get(t), a = !(n?.enabled ?? !0);
|
|
27
|
-
|
|
28
|
+
_(t), r("medium");
|
|
28
29
|
try {
|
|
29
|
-
await
|
|
30
|
+
await p({
|
|
30
31
|
...e,
|
|
31
32
|
enabled: a,
|
|
32
33
|
frequency: n?.frequency || "IMMEDIATE"
|
|
33
|
-
}),
|
|
34
|
+
}), h({
|
|
34
35
|
action: "set",
|
|
35
36
|
scope: e.scope,
|
|
36
37
|
channel: e.channel,
|
|
37
38
|
type: e.type,
|
|
38
39
|
enabled: a
|
|
39
|
-
}),
|
|
40
|
+
}), x({
|
|
40
41
|
key: t,
|
|
41
42
|
type: "success",
|
|
42
43
|
message: l("notifications.preferenceSaved", "Preference saved.")
|
|
43
44
|
}), i("success");
|
|
44
45
|
} catch {
|
|
45
|
-
|
|
46
|
+
x({
|
|
46
47
|
key: t,
|
|
47
48
|
type: "error",
|
|
48
49
|
message: l("notifications.preferenceSaveFailed", "Could not save preference.")
|
|
49
50
|
}), i("error");
|
|
50
51
|
} finally {
|
|
51
|
-
|
|
52
|
+
_(null);
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
55
|
resetPreference: async (e) => {
|
|
55
56
|
let t = u.get(e);
|
|
56
57
|
if (t) {
|
|
57
|
-
|
|
58
|
+
_(e);
|
|
58
59
|
try {
|
|
59
|
-
await
|
|
60
|
+
await m(t.id), h({
|
|
60
61
|
action: "reset",
|
|
61
62
|
scope: t.scope,
|
|
62
63
|
channel: t.channel,
|
|
63
64
|
type: t.type
|
|
64
|
-
}),
|
|
65
|
+
}), x({
|
|
65
66
|
key: e,
|
|
66
67
|
type: "success",
|
|
67
68
|
message: l("notifications.preferenceReset", "Preference reset.")
|
|
68
69
|
});
|
|
69
70
|
} catch {
|
|
70
|
-
|
|
71
|
+
x({
|
|
71
72
|
key: e,
|
|
72
73
|
type: "error",
|
|
73
74
|
message: l("notifications.preferenceResetFailed", "Could not reset preference.")
|
|
74
75
|
});
|
|
75
76
|
} finally {
|
|
76
|
-
|
|
77
|
+
_(null);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
}
|