@notificationapi/react 0.0.25 → 0.0.27
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.
|
@@ -523,59 +523,57 @@ function Le() {
|
|
|
523
523
|
const e = ie(oe);
|
|
524
524
|
if (!e || !e.preferences)
|
|
525
525
|
return null;
|
|
526
|
-
const n = e.preferences.notifications.map(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
)
|
|
532
|
-
|
|
533
|
-
)
|
|
534
|
-
(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
);
|
|
526
|
+
const n = e.preferences.notifications.sort((t, o) => t.title.localeCompare(o.title)).map((t) => {
|
|
527
|
+
var f, r, s;
|
|
528
|
+
const o = (f = e.preferences) == null ? void 0 : f.preferences.filter(
|
|
529
|
+
(a) => a.notificationId === t.notificationId && !a.subNotificationId
|
|
530
|
+
), i = (r = e.preferences) == null ? void 0 : r.preferences.filter(
|
|
531
|
+
(a) => a.notificationId === t.notificationId && a.subNotificationId
|
|
532
|
+
), c = (s = e.preferences) == null ? void 0 : s.subNotifications.filter(
|
|
533
|
+
(a) => i == null ? void 0 : i.find(
|
|
534
|
+
(v) => v.subNotificationId === a.subNotificationId
|
|
535
|
+
)
|
|
536
|
+
);
|
|
537
|
+
return {
|
|
538
|
+
label: t.title,
|
|
539
|
+
key: t.notificationId,
|
|
540
|
+
children: /* @__PURE__ */ ae(G, { children: [
|
|
541
|
+
/* @__PURE__ */ B(
|
|
542
|
+
L,
|
|
543
|
+
{
|
|
544
|
+
notification: t,
|
|
545
|
+
preferences: o || [],
|
|
546
|
+
updateDelivery: e.updateDelivery
|
|
547
|
+
},
|
|
548
|
+
t.notificationId
|
|
549
|
+
),
|
|
550
|
+
c == null ? void 0 : c.map((a) => /* @__PURE__ */ B(
|
|
551
|
+
q,
|
|
552
|
+
{
|
|
553
|
+
bordered: !1,
|
|
554
|
+
items: [
|
|
555
|
+
{
|
|
556
|
+
label: a.title,
|
|
557
|
+
key: a.subNotificationId,
|
|
558
|
+
children: /* @__PURE__ */ B(
|
|
559
|
+
L,
|
|
560
|
+
{
|
|
561
|
+
notification: t,
|
|
562
|
+
preferences: i || [],
|
|
563
|
+
updateDelivery: e.updateDelivery,
|
|
564
|
+
subNotificationId: a.subNotificationId
|
|
565
|
+
},
|
|
566
|
+
a.subNotificationId
|
|
567
|
+
)
|
|
568
|
+
}
|
|
569
|
+
],
|
|
570
|
+
defaultActiveKey: []
|
|
571
|
+
},
|
|
572
|
+
a.subNotificationId
|
|
573
|
+
))
|
|
574
|
+
] })
|
|
575
|
+
};
|
|
576
|
+
});
|
|
579
577
|
return /* @__PURE__ */ B(G, { children: /* @__PURE__ */ B(q, { items: n, defaultActiveKey: [] }) });
|
|
580
578
|
}
|
|
581
579
|
export {
|
|
@@ -10,6 +10,12 @@ export type Context = {
|
|
|
10
10
|
markAsUnarchived: (ids: string[] | 'ALL') => void;
|
|
11
11
|
markAsClicked: (ids: string[]) => void;
|
|
12
12
|
updateDelivery: (notificationId: string, channel: Channels, delivery: DeliveryOptionsForEmail | DeliveryOptionsForInappWeb | BaseDeliveryOptions, subNotificationId?: string) => void;
|
|
13
|
+
updateDeliveries: (params: {
|
|
14
|
+
notificationId: string;
|
|
15
|
+
channel: Channels;
|
|
16
|
+
delivery: DeliveryOptionsForEmail | DeliveryOptionsForInappWeb | BaseDeliveryOptions;
|
|
17
|
+
subNotificationId?: string;
|
|
18
|
+
}[]) => void;
|
|
13
19
|
};
|
|
14
20
|
export declare const NotificationAPIContext: import('react').Context<Context | undefined>;
|
|
15
21
|
type Props = {
|
|
@@ -20,6 +26,8 @@ type Props = {
|
|
|
20
26
|
wsURL?: string;
|
|
21
27
|
initialLoadMaxCount?: number;
|
|
22
28
|
initialLoadMaxAge?: Date;
|
|
29
|
+
playSoundOnNewNotification?: boolean;
|
|
30
|
+
newNotificationSoundPath?: string;
|
|
23
31
|
};
|
|
24
32
|
export declare const NotificationAPIProvider: React.FunctionComponent<PropsWithChildren<Props>> & {
|
|
25
33
|
useNotificationAPIContext: typeof useNotificationAPIContext;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
`https://${c}/${
|
|
1
|
+
import { jsx as B } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as F, useState as N, useCallback as b, useMemo as G, useRef as m, useEffect as M, useContext as J } from "react";
|
|
3
|
+
const _ = async (e, c, r, a, f, w, p) => {
|
|
4
|
+
const h = z(a, f, w), l = await fetch(
|
|
5
|
+
`https://${c}/${a}/users/${encodeURIComponent(
|
|
6
6
|
f
|
|
7
|
-
)}/${
|
|
7
|
+
)}/${r}`,
|
|
8
8
|
{
|
|
9
9
|
method: e,
|
|
10
|
-
body: JSON.stringify(
|
|
10
|
+
body: JSON.stringify(p),
|
|
11
11
|
headers: {
|
|
12
|
-
Authorization: `Basic ${
|
|
12
|
+
Authorization: `Basic ${h}`
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
);
|
|
@@ -18,7 +18,7 @@ const J = async (e, c, d, r, f, I, h) => {
|
|
|
18
18
|
} catch {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, z = (e, c, r) => btoa(r ? e + ":" + c + ":" + r : e + ":" + c), U = {
|
|
22
22
|
host: "api.notificationapi.com",
|
|
23
23
|
websocketHost: "ws.notificationapi.com",
|
|
24
24
|
userId: "",
|
|
@@ -31,43 +31,43 @@ const J = async (e, c, d, r, f, I, h) => {
|
|
|
31
31
|
onNewInAppNotifications: void 0,
|
|
32
32
|
keepWebSocketAliveForSeconds: 86400
|
|
33
33
|
// 24 hours
|
|
34
|
-
},
|
|
35
|
-
config:
|
|
34
|
+
}, o = {
|
|
35
|
+
config: U,
|
|
36
36
|
init: function(e) {
|
|
37
|
-
return this.config = { ...
|
|
37
|
+
return this.config = { ...U, ...e }, {
|
|
38
38
|
...this
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
41
|
rest: {
|
|
42
|
-
generic: function(e, c,
|
|
43
|
-
return
|
|
42
|
+
generic: function(e, c, r) {
|
|
43
|
+
return _(
|
|
44
44
|
e,
|
|
45
|
-
|
|
45
|
+
o.config.host,
|
|
46
46
|
c,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
o.config.clientId,
|
|
48
|
+
o.config.userId,
|
|
49
|
+
o.config.hashedUserId,
|
|
50
|
+
r
|
|
51
51
|
);
|
|
52
52
|
},
|
|
53
53
|
getNotifications: function(e, c) {
|
|
54
|
-
return
|
|
54
|
+
return o.rest.generic(
|
|
55
55
|
"GET",
|
|
56
56
|
`notifications/INAPP_WEB?count=${c}&before=${e}`
|
|
57
57
|
);
|
|
58
58
|
},
|
|
59
59
|
patchNotifications: function(e) {
|
|
60
|
-
return
|
|
60
|
+
return o.rest.generic(
|
|
61
61
|
"PATCH",
|
|
62
62
|
"notifications/INAPP_WEB",
|
|
63
63
|
e
|
|
64
64
|
);
|
|
65
65
|
},
|
|
66
66
|
getPreferences: function() {
|
|
67
|
-
return
|
|
67
|
+
return o.rest.generic("GET", "preferences");
|
|
68
68
|
},
|
|
69
69
|
postPreferences: function(e) {
|
|
70
|
-
return
|
|
70
|
+
return o.rest.generic(
|
|
71
71
|
"POST",
|
|
72
72
|
"preferences",
|
|
73
73
|
e
|
|
@@ -77,24 +77,24 @@ const J = async (e, c, d, r, f, I, h) => {
|
|
|
77
77
|
websocket: {
|
|
78
78
|
object: void 0,
|
|
79
79
|
connect: function() {
|
|
80
|
-
let e = `wss://${
|
|
81
|
-
return
|
|
82
|
-
const
|
|
83
|
-
if (!(!
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
let e = `wss://${o.config.websocketHost}?userId=${encodeURIComponent(o.config.userId)}&envId=${o.config.clientId}`;
|
|
81
|
+
return o.config.hashedUserId && (e += `&userIdHash=${encodeURIComponent(o.config.hashedUserId)}`), o.websocket.object = new WebSocket(e), o.websocket.object.onmessage = (c) => {
|
|
82
|
+
const r = JSON.parse(c.data);
|
|
83
|
+
if (!(!r || !r.route) && r.route === "inapp_web/new_notifications") {
|
|
84
|
+
const a = r;
|
|
85
|
+
o.config.onNewInAppNotifications && o.config.onNewInAppNotifications(
|
|
86
|
+
a.payload.notifications
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
-
},
|
|
89
|
+
}, o.websocket.object;
|
|
90
90
|
},
|
|
91
91
|
disconnect: function(e) {
|
|
92
92
|
var c;
|
|
93
|
-
|
|
93
|
+
o.websocket.object && ((c = o.websocket.object) == null || c.close(), e && e(o.websocket.object));
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
openWebSocket: function() {
|
|
97
|
-
return
|
|
97
|
+
return o.websocket.connect(() => {
|
|
98
98
|
setTimeout(
|
|
99
99
|
() => {
|
|
100
100
|
this.websocket.disconnect(() => {
|
|
@@ -106,23 +106,23 @@ const J = async (e, c, d, r, f, I, h) => {
|
|
|
106
106
|
});
|
|
107
107
|
},
|
|
108
108
|
getInAppNotifications: async (e) => {
|
|
109
|
-
const c = e.maxCountNeeded ||
|
|
110
|
-
let
|
|
111
|
-
for (;
|
|
112
|
-
const
|
|
109
|
+
const c = e.maxCountNeeded || o.config.getInAppDefaultCount, r = e.oldestNeeded || o.config.getInAppDefaultOldest;
|
|
110
|
+
let a = [], f = e.before, w = !0, p = !0;
|
|
111
|
+
for (; p; ) {
|
|
112
|
+
const h = (await o.rest.getNotifications(
|
|
113
113
|
f,
|
|
114
114
|
c
|
|
115
115
|
)).notifications.filter(
|
|
116
|
-
(l) => !
|
|
116
|
+
(l) => !a.find((g) => g.id === l.id)
|
|
117
117
|
);
|
|
118
|
-
f =
|
|
119
|
-
(l,
|
|
118
|
+
f = h.reduce(
|
|
119
|
+
(l, g) => l < g.date ? l : g.date,
|
|
120
120
|
e.before
|
|
121
|
-
),
|
|
121
|
+
), a = [...a, ...h], w = h.length > 0, p = !0, (!w || a.length >= c || f < r) && (p = !1);
|
|
122
122
|
}
|
|
123
123
|
return {
|
|
124
|
-
items:
|
|
125
|
-
hasMore:
|
|
124
|
+
items: a,
|
|
125
|
+
hasMore: w,
|
|
126
126
|
oldestReceived: f
|
|
127
127
|
};
|
|
128
128
|
},
|
|
@@ -130,154 +130,164 @@ const J = async (e, c, d, r, f, I, h) => {
|
|
|
130
130
|
const c = {
|
|
131
131
|
trackingIds: e.ids
|
|
132
132
|
};
|
|
133
|
-
return e.archived === !0 ? c.archived = (/* @__PURE__ */ new Date()).toISOString() : e.archived === !1 && (c.archived = null), e.clicked === !0 ? c.clicked = (/* @__PURE__ */ new Date()).toISOString() : e.clicked === !1 && (c.clicked = null), e.opened === !0 ? c.opened = (/* @__PURE__ */ new Date()).toISOString() : e.opened === !1 && (c.opened = null),
|
|
133
|
+
return e.archived === !0 ? c.archived = (/* @__PURE__ */ new Date()).toISOString() : e.archived === !1 && (c.archived = null), e.clicked === !0 ? c.clicked = (/* @__PURE__ */ new Date()).toISOString() : e.clicked === !1 && (c.clicked = null), e.opened === !0 ? c.opened = (/* @__PURE__ */ new Date()).toISOString() : e.opened === !1 && (c.opened = null), o.rest.patchNotifications(c);
|
|
134
134
|
},
|
|
135
|
-
getPreferences: async () =>
|
|
136
|
-
updateDeliveryOption: async (e) =>
|
|
137
|
-
},
|
|
135
|
+
getPreferences: async () => o.rest.getPreferences(),
|
|
136
|
+
updateDeliveryOption: async (e) => o.rest.postPreferences([e])
|
|
137
|
+
}, R = F(
|
|
138
138
|
void 0
|
|
139
|
-
),
|
|
140
|
-
const
|
|
139
|
+
), q = (e) => {
|
|
140
|
+
const r = {
|
|
141
141
|
...{
|
|
142
142
|
apiURL: "https://api.notificationapi.com",
|
|
143
143
|
wsURL: "wss://ws.notificationapi.com",
|
|
144
144
|
initialLoadMaxCount: 1e3,
|
|
145
|
-
initialLoadMaxAge: new Date((/* @__PURE__ */ new Date()).setMonth((/* @__PURE__ */ new Date()).getMonth() - 3))
|
|
145
|
+
initialLoadMaxAge: new Date((/* @__PURE__ */ new Date()).setMonth((/* @__PURE__ */ new Date()).getMonth() - 3)),
|
|
146
|
+
playSoundOnNewNotification: !1,
|
|
147
|
+
newNotificationSoundPath: "https://proxy.notificationsounds.com/notification-sounds/elegant-notification-sound/download/file-sounds-1233-elegant.mp3"
|
|
146
148
|
},
|
|
147
149
|
...e
|
|
148
|
-
}, [
|
|
150
|
+
}, [a, f] = N(), [w, p] = N(), [h, l] = N(!1), [g, y] = N((/* @__PURE__ */ new Date()).toISOString()), [A, D] = N(!0), P = b(() => {
|
|
151
|
+
r.playSoundOnNewNotification && new Audio(r.newNotificationSoundPath).play().catch((s) => {
|
|
152
|
+
console.log("Failed to play new notification sound:", s);
|
|
153
|
+
});
|
|
154
|
+
}, [r.newNotificationSoundPath, r.playSoundOnNewNotification]), S = b((n) => {
|
|
149
155
|
const s = (/* @__PURE__ */ new Date()).toISOString();
|
|
150
|
-
f((t) => (
|
|
151
|
-
...
|
|
156
|
+
f((t) => (n = n.filter((i) => !(i.expDate && new Date(i.expDate * 1e3).toISOString() > s || i.date > s)), t ? [
|
|
157
|
+
...n.filter((i) => !t.find((d) => d.id === i.id)),
|
|
152
158
|
...t
|
|
153
|
-
] :
|
|
154
|
-
}, []), u =
|
|
159
|
+
] : n));
|
|
160
|
+
}, []), u = G(() => o.init({
|
|
155
161
|
clientId: e.clientId,
|
|
156
162
|
userId: e.userId,
|
|
157
163
|
hashedUserId: e.hashedUserId,
|
|
158
|
-
onNewInAppNotifications: (
|
|
159
|
-
S(
|
|
164
|
+
onNewInAppNotifications: (n) => {
|
|
165
|
+
P(), S(n);
|
|
160
166
|
}
|
|
161
167
|
}), [
|
|
162
168
|
e.clientId,
|
|
163
169
|
e.userId,
|
|
164
170
|
e.hashedUserId,
|
|
165
|
-
S
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
S,
|
|
172
|
+
P
|
|
173
|
+
]), v = b(
|
|
174
|
+
async (n, s) => {
|
|
175
|
+
const t = await u.rest.getNotifications(n, s);
|
|
176
|
+
y(t.oldestReceived), D(t.couldLoadMore), S(t.notifications);
|
|
170
177
|
},
|
|
171
178
|
[S, u.rest]
|
|
172
|
-
), O = m(
|
|
173
|
-
|
|
174
|
-
O.current =
|
|
175
|
-
}, [
|
|
176
|
-
const k =
|
|
177
|
-
async (
|
|
178
|
-
if (!(!
|
|
179
|
+
), O = m(A), C = m(h), x = m(g);
|
|
180
|
+
M(() => {
|
|
181
|
+
O.current = A, C.current = h, x.current = g;
|
|
182
|
+
}, [A, h, g]);
|
|
183
|
+
const k = b(
|
|
184
|
+
async (n) => {
|
|
185
|
+
if (!(!n && (!O.current || C.current))) {
|
|
179
186
|
l(!0);
|
|
180
187
|
try {
|
|
181
|
-
await
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
await v(
|
|
189
|
+
n ? (/* @__PURE__ */ new Date()).toISOString() : x.current,
|
|
190
|
+
n ? r.initialLoadMaxCount : 1e3
|
|
184
191
|
);
|
|
185
192
|
} finally {
|
|
186
193
|
l(!1);
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
},
|
|
190
|
-
[
|
|
191
|
-
),
|
|
192
|
-
if (!
|
|
197
|
+
[r.initialLoadMaxCount, v]
|
|
198
|
+
), $ = async (n) => {
|
|
199
|
+
if (!a)
|
|
193
200
|
return;
|
|
194
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), t =
|
|
195
|
-
u.updateInAppNotifications({ ids: t, clicked: !0 }), f((
|
|
196
|
-
if (!
|
|
201
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), t = a.filter((i) => n.includes(i.id) && !i.clicked).map((i) => i.id);
|
|
202
|
+
u.updateInAppNotifications({ ids: t, clicked: !0 }), f((i) => {
|
|
203
|
+
if (!i)
|
|
197
204
|
return [];
|
|
198
|
-
const
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
}),
|
|
205
|
+
const d = [...i];
|
|
206
|
+
return d.filter((I) => t.includes(I.id)).forEach((I) => {
|
|
207
|
+
I.clicked = s;
|
|
208
|
+
}), d;
|
|
202
209
|
});
|
|
203
|
-
},
|
|
204
|
-
if (!
|
|
210
|
+
}, E = async () => {
|
|
211
|
+
if (!a)
|
|
205
212
|
return;
|
|
206
|
-
const
|
|
213
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), s = a.filter((t) => !t.opened || !t.seen).map((t) => t.id);
|
|
207
214
|
s.length !== 0 && (u.updateInAppNotifications({
|
|
208
215
|
ids: s,
|
|
209
216
|
opened: !0
|
|
210
217
|
}), f((t) => {
|
|
211
218
|
if (!t)
|
|
212
219
|
return [];
|
|
213
|
-
const
|
|
214
|
-
return
|
|
215
|
-
|
|
216
|
-
}),
|
|
220
|
+
const i = [...t];
|
|
221
|
+
return i.filter((d) => s.includes(d.id)).forEach((d) => {
|
|
222
|
+
d.opened = n, d.seen = !0;
|
|
223
|
+
}), i;
|
|
217
224
|
}));
|
|
218
|
-
},
|
|
219
|
-
if (!
|
|
225
|
+
}, j = async (n) => {
|
|
226
|
+
if (!a)
|
|
220
227
|
return;
|
|
221
|
-
const s =
|
|
228
|
+
const s = a.filter((t) => t.archived && (n === "ALL" || n.includes(t.id))).map((t) => t.id);
|
|
222
229
|
s.length !== 0 && (u.updateInAppNotifications({
|
|
223
230
|
ids: s,
|
|
224
231
|
archived: !1
|
|
225
232
|
}), f((t) => {
|
|
226
233
|
if (!t)
|
|
227
234
|
return [];
|
|
228
|
-
const
|
|
229
|
-
return
|
|
230
|
-
|
|
231
|
-
}),
|
|
235
|
+
const i = [...t];
|
|
236
|
+
return i.filter((d) => s.includes(d.id)).forEach((d) => {
|
|
237
|
+
d.archived = void 0;
|
|
238
|
+
}), i;
|
|
232
239
|
}));
|
|
233
|
-
},
|
|
234
|
-
if (!
|
|
240
|
+
}, T = async (n) => {
|
|
241
|
+
if (!a)
|
|
235
242
|
return;
|
|
236
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), t =
|
|
237
|
-
t.length !== 0 && (u.updateInAppNotifications({ ids: t, archived: !0 }), f((
|
|
238
|
-
if (!
|
|
243
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), t = a.filter((i) => !i.archived && (n === "ALL" || n.includes(i.id))).map((i) => i.id);
|
|
244
|
+
t.length !== 0 && (u.updateInAppNotifications({ ids: t, archived: !0 }), f((i) => {
|
|
245
|
+
if (!i)
|
|
239
246
|
return [];
|
|
240
|
-
const
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
}),
|
|
247
|
+
const d = [...i];
|
|
248
|
+
return d.filter((I) => t.includes(I.id)).forEach((I) => {
|
|
249
|
+
I.archived = s;
|
|
250
|
+
}), d;
|
|
244
251
|
}));
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
notificationId:
|
|
252
|
+
}, W = (n, s, t, i) => L([
|
|
253
|
+
{
|
|
254
|
+
notificationId: n,
|
|
248
255
|
channel: s,
|
|
249
256
|
delivery: t,
|
|
250
|
-
subNotificationId:
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
subNotificationId: i
|
|
258
|
+
}
|
|
259
|
+
]), L = (n) => {
|
|
260
|
+
u.rest.postPreferences(n).then(() => {
|
|
261
|
+
u.getPreferences().then((s) => {
|
|
262
|
+
p(s);
|
|
254
263
|
});
|
|
255
264
|
});
|
|
256
265
|
};
|
|
257
|
-
|
|
258
|
-
f([]), l(!1),
|
|
259
|
-
|
|
266
|
+
M(() => {
|
|
267
|
+
f([]), l(!1), p(void 0), y((/* @__PURE__ */ new Date()).toISOString()), D(!0), k(!0), u.openWebSocket(), u.getPreferences().then((n) => {
|
|
268
|
+
p(n);
|
|
260
269
|
});
|
|
261
270
|
}, [u, k]);
|
|
262
|
-
const
|
|
263
|
-
notifications:
|
|
264
|
-
preferences:
|
|
271
|
+
const H = {
|
|
272
|
+
notifications: a,
|
|
273
|
+
preferences: w,
|
|
265
274
|
loadNotifications: k,
|
|
266
|
-
markAsOpened:
|
|
267
|
-
markAsArchived:
|
|
268
|
-
markAsUnarchived:
|
|
269
|
-
markAsClicked:
|
|
270
|
-
updateDelivery:
|
|
275
|
+
markAsOpened: E,
|
|
276
|
+
markAsArchived: T,
|
|
277
|
+
markAsUnarchived: j,
|
|
278
|
+
markAsClicked: $,
|
|
279
|
+
updateDelivery: W,
|
|
280
|
+
updateDeliveries: L
|
|
271
281
|
};
|
|
272
|
-
return /* @__PURE__ */
|
|
273
|
-
},
|
|
274
|
-
const e =
|
|
282
|
+
return /* @__PURE__ */ B(R.Provider, { value: H, children: e.children });
|
|
283
|
+
}, K = () => {
|
|
284
|
+
const e = J(R);
|
|
275
285
|
if (!e)
|
|
276
286
|
throw new Error("useMyContext must be used within a MyProvider");
|
|
277
287
|
return e;
|
|
278
288
|
};
|
|
279
|
-
|
|
289
|
+
q.useNotificationAPIContext = K;
|
|
280
290
|
export {
|
|
281
|
-
|
|
282
|
-
|
|
291
|
+
R as NotificationAPIContext,
|
|
292
|
+
q as NotificationAPIProvider
|
|
283
293
|
};
|