@notificationapi/react 0.0.12 → 0.0.14
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/assets/Inbox.js +233 -222
- package/dist/assets/Notification.js +1 -1
- package/dist/components/Notifications/Inbox.d.ts +3 -2
- package/dist/components/Notifications/Notification.d.ts +4 -2
- package/dist/components/Notifications/NotificationCounter.d.ts +1 -1
- package/dist/components/Notifications/NotificationCounter.js +3 -3
- package/dist/components/Notifications/NotificationFeed.d.ts +4 -1
- package/dist/components/Notifications/NotificationFeed.js +16 -11
- package/dist/components/Notifications/NotificationLauncher.js +19 -14
- package/dist/components/Notifications/NotificationPopup.d.ts +4 -1
- package/dist/components/Notifications/UnreadBadge.d.ts +2 -1
- package/dist/components/Provider/index.d.ts +15 -12
- package/dist/components/Provider/index.js +81 -75
- package/dist/interface.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4492,7 +4492,7 @@ const pu = Un.div`
|
|
|
4492
4492
|
&:hover .notification-archive-button {
|
|
4493
4493
|
visibility: ${(e) => e.$archived ? "hidden" : "visible"};
|
|
4494
4494
|
}
|
|
4495
|
-
`, wu = (e) => /* @__PURE__ */ lt(
|
|
4495
|
+
`, wu = (e) => e.renderer ? e.renderer(e.notification) : /* @__PURE__ */ lt(
|
|
4496
4496
|
pu,
|
|
4497
4497
|
{
|
|
4498
4498
|
$redirect: !!e.notification.redirectURL,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { ImageShape } from './Notification';
|
|
2
2
|
import { NotificationPopupProps } from './NotificationPopup';
|
|
3
|
+
import { InAppNotification } from '../../interface';
|
|
3
4
|
|
|
4
5
|
export declare enum Pagination {
|
|
5
6
|
INFINITE_SCROLL = "infinite_scroll",
|
|
6
7
|
PAGINATED = "paginated"
|
|
7
8
|
}
|
|
8
|
-
type InboxProps = {
|
|
9
|
+
export type InboxProps = {
|
|
9
10
|
pagination: keyof typeof Pagination;
|
|
10
11
|
maxHeight: number;
|
|
11
12
|
filter: NotificationPopupProps["filter"];
|
|
12
13
|
imageShape: keyof typeof ImageShape;
|
|
13
14
|
pageSize: number;
|
|
14
15
|
pagePosition: NotificationPopupProps["pagePosition"];
|
|
16
|
+
notificationRenderer: ((notification: InAppNotification) => JSX.Element) | undefined;
|
|
15
17
|
};
|
|
16
18
|
export declare const Inbox: React.FC<InboxProps>;
|
|
17
|
-
export {};
|
|
@@ -4,9 +4,11 @@ export declare enum ImageShape {
|
|
|
4
4
|
square = "square",
|
|
5
5
|
circle = "circle"
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type NotificationProps = {
|
|
8
8
|
notification: InAppNotification;
|
|
9
9
|
markAsArchived: (ids: string[] | "ALL") => void;
|
|
10
10
|
markAsClicked: (id: string) => void;
|
|
11
11
|
imageShape: keyof typeof ImageShape;
|
|
12
|
-
|
|
12
|
+
renderer?: (notification: InAppNotification) => JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
export declare const Notification: (props: NotificationProps) => JSX.Element;
|
|
@@ -2,6 +2,6 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { UnreadBadgeProps } from './UnreadBadge';
|
|
3
3
|
|
|
4
4
|
export type NotificationCounterProps = Omit<UnreadBadgeProps, "count"> & {
|
|
5
|
-
|
|
5
|
+
count?: UnreadBadgeProps["count"];
|
|
6
6
|
};
|
|
7
7
|
export declare const NotificationCounter: React.FC<PropsWithChildren<NotificationCounterProps>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { UnreadBadge as r } from "./UnreadBadge.js";
|
|
3
|
-
const
|
|
4
|
-
const t = o.
|
|
3
|
+
const e = (o) => {
|
|
4
|
+
const t = o.count || "COUNT_UNOPENED_NOTIFICATIONS";
|
|
5
5
|
return /* @__PURE__ */ n(r, { ...o, count: t });
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
e as NotificationCounter
|
|
9
9
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pagination } from './Inbox';
|
|
2
|
-
import { ImageShape } from './Notification';
|
|
2
|
+
import { ImageShape, NotificationProps } from './Notification';
|
|
3
3
|
import { Filter } from './NotificationPopup';
|
|
4
4
|
import { InAppNotification } from '../../interface';
|
|
5
5
|
|
|
@@ -11,5 +11,8 @@ export type NotificationFeedProps = {
|
|
|
11
11
|
infiniteScrollHeight?: number;
|
|
12
12
|
style?: React.CSSProperties;
|
|
13
13
|
filter?: keyof typeof Filter | ((n: InAppNotification) => boolean);
|
|
14
|
+
renderers?: {
|
|
15
|
+
notification?: NotificationProps["renderer"];
|
|
16
|
+
};
|
|
14
17
|
};
|
|
15
18
|
export declare const NotificationFeed: React.FC<NotificationFeedProps>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { F as
|
|
4
|
-
import { NotificationAPIContext as
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as r, useEffect as g } from "react";
|
|
3
|
+
import { F as f, I as l } from "../../assets/Inbox.js";
|
|
4
|
+
import { NotificationAPIContext as c } from "../Provider/index.js";
|
|
5
5
|
const h = (i) => {
|
|
6
|
+
var n;
|
|
6
7
|
const e = {
|
|
7
8
|
imageShape: i.imageShape || "circle",
|
|
8
9
|
pagination: i.pagination || "INFINITE_SCROLL",
|
|
9
10
|
pageSize: i.pageSize || 10,
|
|
10
11
|
pagePosition: i.pagePosition || "top",
|
|
11
12
|
style: i.style || {},
|
|
12
|
-
filter: i.filter ||
|
|
13
|
-
infiniteScrollHeight: i.infiniteScrollHeight ? i.infiniteScrollHeight : window.innerHeight * 0.75
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
filter: i.filter || f.ALL,
|
|
14
|
+
infiniteScrollHeight: i.infiniteScrollHeight ? i.infiniteScrollHeight : window.innerHeight * 0.75,
|
|
15
|
+
renderers: {
|
|
16
|
+
notification: (n = i.renderers) == null ? void 0 : n.notification
|
|
17
|
+
}
|
|
18
|
+
}, t = r(c);
|
|
19
|
+
return t ? (g(() => {
|
|
16
20
|
t.markAsOpened();
|
|
17
21
|
const a = setInterval(() => {
|
|
18
22
|
t.markAsOpened();
|
|
19
23
|
}, 5e3);
|
|
20
24
|
return () => clearInterval(a);
|
|
21
|
-
}, []), /* @__PURE__ */
|
|
25
|
+
}, []), /* @__PURE__ */ o(
|
|
22
26
|
"div",
|
|
23
27
|
{
|
|
24
28
|
style: {
|
|
@@ -27,7 +31,7 @@ const h = (i) => {
|
|
|
27
31
|
background: "#fff",
|
|
28
32
|
...i.style
|
|
29
33
|
},
|
|
30
|
-
children: /* @__PURE__ */
|
|
34
|
+
children: /* @__PURE__ */ o(
|
|
31
35
|
l,
|
|
32
36
|
{
|
|
33
37
|
maxHeight: e.infiniteScrollHeight,
|
|
@@ -35,7 +39,8 @@ const h = (i) => {
|
|
|
35
39
|
filter: e.filter,
|
|
36
40
|
imageShape: e.imageShape,
|
|
37
41
|
pageSize: e.pageSize,
|
|
38
|
-
pagePosition: e.pagePosition
|
|
42
|
+
pagePosition: e.pagePosition,
|
|
43
|
+
notificationRenderer: e.renderers.notification
|
|
39
44
|
}
|
|
40
45
|
)
|
|
41
46
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import { I as
|
|
2
|
+
import { I as r } from "../../assets/Inbox.js";
|
|
3
3
|
import { UnreadBadge as f } from "./UnreadBadge.js";
|
|
4
|
-
import { useContext as
|
|
4
|
+
import { useContext as d } from "react";
|
|
5
5
|
import { NotificationAPIContext as g } from "../Provider/index.js";
|
|
6
6
|
import { P as u } from "../../assets/index.js";
|
|
7
|
-
import { B as
|
|
8
|
-
import { R as
|
|
7
|
+
import { B as c } from "../../assets/button.js";
|
|
8
|
+
import { R as h } from "../../assets/BellOutlined.js";
|
|
9
9
|
var l = /* @__PURE__ */ ((t) => (t.TOP_LEFT = "top-left", t.TOP_RIGHT = "top-right", t.BOTTOM_LEFT = "bottom-left", t.BOTTOM_RIGHT = "bottom-right", t))(l || {});
|
|
10
|
-
const
|
|
10
|
+
const y = (t) => {
|
|
11
|
+
var n;
|
|
11
12
|
const e = {
|
|
12
13
|
buttonWidth: t.buttonWidth || 40,
|
|
13
14
|
buttonHeight: t.buttonHeight || 40,
|
|
@@ -27,8 +28,11 @@ const S = (t) => {
|
|
|
27
28
|
offsetY: t.offsetY || 16,
|
|
28
29
|
position: t.position || "BOTTOM_RIGHT",
|
|
29
30
|
count: t.count || "COUNT_UNOPENED_NOTIFICATIONS",
|
|
30
|
-
filter: t.filter || "ALL"
|
|
31
|
-
|
|
31
|
+
filter: t.filter || "ALL",
|
|
32
|
+
renderers: {
|
|
33
|
+
notification: (n = t.renderers) == null ? void 0 : n.notification
|
|
34
|
+
}
|
|
35
|
+
}, o = d(g);
|
|
32
36
|
return o ? /* @__PURE__ */ i(
|
|
33
37
|
"div",
|
|
34
38
|
{
|
|
@@ -44,14 +48,15 @@ const S = (t) => {
|
|
|
44
48
|
autoAdjustOverflow: !0,
|
|
45
49
|
trigger: "click",
|
|
46
50
|
content: /* @__PURE__ */ i(
|
|
47
|
-
|
|
51
|
+
r,
|
|
48
52
|
{
|
|
49
53
|
maxHeight: 500,
|
|
50
54
|
pagination: e.pagination,
|
|
51
55
|
filter: e.filter,
|
|
52
56
|
imageShape: e.imageShape,
|
|
53
57
|
pageSize: e.pageSize,
|
|
54
|
-
pagePosition: e.pagePosition
|
|
58
|
+
pagePosition: e.pagePosition,
|
|
59
|
+
notificationRenderer: e.renderers.notification
|
|
55
60
|
}
|
|
56
61
|
),
|
|
57
62
|
arrow: !1,
|
|
@@ -59,8 +64,8 @@ const S = (t) => {
|
|
|
59
64
|
padding: "0 16px",
|
|
60
65
|
minWidth: e.popupWidth
|
|
61
66
|
},
|
|
62
|
-
onOpenChange: (
|
|
63
|
-
|
|
67
|
+
onOpenChange: (a) => {
|
|
68
|
+
a && o.markAsOpened();
|
|
64
69
|
},
|
|
65
70
|
children: /* @__PURE__ */ i(
|
|
66
71
|
"div",
|
|
@@ -78,10 +83,10 @@ const S = (t) => {
|
|
|
78
83
|
},
|
|
79
84
|
count: e.count,
|
|
80
85
|
children: /* @__PURE__ */ i(
|
|
81
|
-
|
|
86
|
+
c,
|
|
82
87
|
{
|
|
83
88
|
icon: /* @__PURE__ */ i(
|
|
84
|
-
|
|
89
|
+
h,
|
|
85
90
|
{
|
|
86
91
|
style: {
|
|
87
92
|
fontSize: e.buttonIconSize
|
|
@@ -106,6 +111,6 @@ const S = (t) => {
|
|
|
106
111
|
) : null;
|
|
107
112
|
};
|
|
108
113
|
export {
|
|
109
|
-
|
|
114
|
+
y as NotificationLauncher,
|
|
110
115
|
l as Position
|
|
111
116
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Pagination } from './Inbox';
|
|
2
2
|
import { UnreadBadgeProps } from './UnreadBadge';
|
|
3
|
-
import { ImageShape } from './Notification';
|
|
3
|
+
import { ImageShape, NotificationProps } from './Notification';
|
|
4
4
|
import { InAppNotification } from '../../interface';
|
|
5
5
|
|
|
6
6
|
export declare enum Filter {
|
|
@@ -21,5 +21,8 @@ export type NotificationPopupProps = {
|
|
|
21
21
|
unreadBadgeProps?: UnreadBadgeProps;
|
|
22
22
|
count?: UnreadBadgeProps["count"];
|
|
23
23
|
filter?: keyof typeof Filter | ((n: InAppNotification) => boolean);
|
|
24
|
+
renderers?: {
|
|
25
|
+
notification?: NotificationProps["renderer"];
|
|
26
|
+
};
|
|
24
27
|
};
|
|
25
28
|
export declare const NotificationPopup: React.FC<NotificationPopupProps>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { NotificationPopupProps } from './NotificationPopup';
|
|
3
|
+
import { InAppNotification } from '../../interface';
|
|
3
4
|
|
|
4
5
|
export type UnreadBadgeProps = {
|
|
5
6
|
color?: "blue" | "purple" | "cyan" | "green" | "magenta" | "pink" | "red" | "orange" | "yellow" | "volcano" | "geekblue" | "lime" | "gold" | undefined;
|
|
@@ -8,7 +9,7 @@ export type UnreadBadgeProps = {
|
|
|
8
9
|
showZero?: boolean;
|
|
9
10
|
size?: "default" | "small";
|
|
10
11
|
style?: React.CSSProperties;
|
|
11
|
-
count?: keyof typeof COUNT_TYPE | ((notification:
|
|
12
|
+
count?: keyof typeof COUNT_TYPE | ((notification: InAppNotification) => boolean);
|
|
12
13
|
filter?: NotificationPopupProps["filter"];
|
|
13
14
|
};
|
|
14
15
|
export declare enum COUNT_TYPE {
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { InAppNotification } from '../../interface';
|
|
3
3
|
|
|
4
|
-
type Props = {
|
|
5
|
-
clientId: string;
|
|
6
|
-
userId: string;
|
|
7
|
-
hashedUserId?: string;
|
|
8
|
-
apiURL?: string;
|
|
9
|
-
wsURL?: string;
|
|
10
|
-
initialLoadMaxCount?: number;
|
|
11
|
-
initialLoadMaxAge?: Date;
|
|
12
|
-
};
|
|
13
4
|
export declare const NOTIFICATION_ACTIONS: {
|
|
14
5
|
opened: string;
|
|
15
6
|
clicked: string;
|
|
@@ -34,7 +25,7 @@ export declare enum DeliveryOptions {
|
|
|
34
25
|
WEEKLY = "weekly",
|
|
35
26
|
MONTHLY = "monthly"
|
|
36
27
|
}
|
|
37
|
-
export interface
|
|
28
|
+
export interface NotificationConfig {
|
|
38
29
|
envId: string;
|
|
39
30
|
notificationId: string;
|
|
40
31
|
title: string;
|
|
@@ -91,7 +82,7 @@ export interface Preferences {
|
|
|
91
82
|
notificationId: string;
|
|
92
83
|
title: string;
|
|
93
84
|
channels: Channels[];
|
|
94
|
-
options:
|
|
85
|
+
options: NotificationConfig["options"];
|
|
95
86
|
}[];
|
|
96
87
|
subNotifications: {
|
|
97
88
|
notificationId: string;
|
|
@@ -109,5 +100,17 @@ export type Context = {
|
|
|
109
100
|
updateDelivery: (notificationId: string, channel: Channels, delivery: DeliveryOptions, subNotificationId?: string) => void;
|
|
110
101
|
};
|
|
111
102
|
export declare const NotificationAPIContext: import('react').Context<Context | undefined>;
|
|
112
|
-
|
|
103
|
+
type Props = {
|
|
104
|
+
clientId: string;
|
|
105
|
+
userId: string;
|
|
106
|
+
hashedUserId?: string;
|
|
107
|
+
apiURL?: string;
|
|
108
|
+
wsURL?: string;
|
|
109
|
+
initialLoadMaxCount?: number;
|
|
110
|
+
initialLoadMaxAge?: Date;
|
|
111
|
+
};
|
|
112
|
+
export declare const NotificationAPIProvider: React.FunctionComponent<PropsWithChildren<Props>> & {
|
|
113
|
+
useNotificationAPIContext: typeof useNotificationAPIContext;
|
|
114
|
+
};
|
|
115
|
+
declare const useNotificationAPIContext: () => Context;
|
|
113
116
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { api as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as W } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as _, useState as f, useEffect as y, useContext as v } from "react";
|
|
3
|
+
import { api as s } from "../../api.js";
|
|
4
|
+
const q = {
|
|
5
5
|
opened: "opened",
|
|
6
6
|
clicked: "clicked",
|
|
7
7
|
archived: "archived",
|
|
@@ -9,10 +9,10 @@ const j = {
|
|
|
9
9
|
actioned1: "actioned1",
|
|
10
10
|
actioned2: "actioned2"
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
const
|
|
12
|
+
var B = /* @__PURE__ */ ((e) => (e.EMAIL = "EMAIL", e.INAPP_WEB = "INAPP_WEB", e.SMS = "SMS", e.CALL = "CALL", e.PUSH = "PUSH", e.WEB_PUSH = "WEB_PUSH", e))(B || {}), $ = /* @__PURE__ */ ((e) => (e.OFF = "off", e.INSTANT = "instant", e.HOURLY = "hourly", e.DAILY = "daily", e.WEEKLY = "weekly", e.MONTHLY = "monthly", e))($ || {});
|
|
13
|
+
const g = _(
|
|
14
14
|
void 0
|
|
15
|
-
),
|
|
15
|
+
), b = (e) => {
|
|
16
16
|
const c = {
|
|
17
17
|
...{
|
|
18
18
|
apiURL: "https://api.notificationapi.com",
|
|
@@ -21,51 +21,51 @@ const y = x(
|
|
|
21
21
|
initialLoadMaxAge: new Date((/* @__PURE__ */ new Date()).setMonth((/* @__PURE__ */ new Date()).getMonth() - 3))
|
|
22
22
|
},
|
|
23
23
|
...e
|
|
24
|
-
}, [
|
|
24
|
+
}, [d, u] = f(), [N, w] = f(), [U, S] = f(!1), [E, M] = f((/* @__PURE__ */ new Date()).toISOString()), [m, T] = f(!0), A = (o) => {
|
|
25
25
|
const n = (/* @__PURE__ */ new Date()).toISOString();
|
|
26
|
-
u((t) => (
|
|
27
|
-
...
|
|
26
|
+
u((t) => (o = o.filter((i) => !(i.expDate && new Date(i.expDate * 1e3).toISOString() > n || i.date > n)), t ? [
|
|
27
|
+
...o.filter((i) => !t.find((a) => a.id === i.id)),
|
|
28
28
|
...t
|
|
29
|
-
] :
|
|
30
|
-
},
|
|
29
|
+
] : o));
|
|
30
|
+
}, k = async (o, n) => (await s(
|
|
31
31
|
c.apiURL,
|
|
32
32
|
"GET",
|
|
33
|
-
`notifications/INAPP_WEB?count=${
|
|
33
|
+
`notifications/INAPP_WEB?count=${o}&before=${n}`,
|
|
34
34
|
e.clientId,
|
|
35
35
|
e.userId,
|
|
36
36
|
e.hashedUserId
|
|
37
|
-
)).notifications,
|
|
38
|
-
let i = [],
|
|
37
|
+
)).notifications, x = async (o, n, t) => {
|
|
38
|
+
let i = [], a = o, r = !0, h = !0;
|
|
39
39
|
for (; h; ) {
|
|
40
|
-
const L = (await
|
|
40
|
+
const L = (await k(
|
|
41
41
|
n,
|
|
42
|
-
new Date(
|
|
42
|
+
new Date(a).getTime()
|
|
43
43
|
)).filter(
|
|
44
44
|
(I) => !i.find((l) => l.id === I.id)
|
|
45
45
|
);
|
|
46
|
-
|
|
46
|
+
a = L.reduce(
|
|
47
47
|
(I, l) => I < l.date ? I : l.date,
|
|
48
|
-
|
|
49
|
-
), i = [...i, ...L],
|
|
48
|
+
o
|
|
49
|
+
), i = [...i, ...L], r = L.length > 0, h = !0, (!r || i.length >= n || t && a < t) && (h = !1);
|
|
50
50
|
}
|
|
51
51
|
return {
|
|
52
52
|
notifications: i,
|
|
53
|
-
couldLoadMore:
|
|
54
|
-
oldestReceived:
|
|
53
|
+
couldLoadMore: r,
|
|
54
|
+
oldestReceived: a
|
|
55
55
|
};
|
|
56
|
-
},
|
|
56
|
+
}, P = async (o) => {
|
|
57
57
|
if (!m || U)
|
|
58
58
|
return;
|
|
59
|
-
|
|
60
|
-
const n = await
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
S(!0);
|
|
60
|
+
const n = await x(
|
|
61
|
+
E,
|
|
62
|
+
o ? c.initialLoadMaxCount : 1e3,
|
|
63
|
+
o ? c.initialLoadMaxAge.toISOString() : void 0
|
|
64
64
|
);
|
|
65
|
-
|
|
66
|
-
}, R = async (
|
|
65
|
+
M(n.oldestReceived), T(n.couldLoadMore), A(n.notifications), S(!1);
|
|
66
|
+
}, R = async (o) => {
|
|
67
67
|
const n = (/* @__PURE__ */ new Date()).toISOString();
|
|
68
|
-
|
|
68
|
+
s(
|
|
69
69
|
c.apiURL,
|
|
70
70
|
"PATCH",
|
|
71
71
|
"notifications/INAPP_WEB",
|
|
@@ -73,20 +73,20 @@ const y = x(
|
|
|
73
73
|
e.userId,
|
|
74
74
|
e.hashedUserId,
|
|
75
75
|
{
|
|
76
|
-
trackingIds: [
|
|
76
|
+
trackingIds: [o],
|
|
77
77
|
clicked: n
|
|
78
78
|
}
|
|
79
79
|
), u((t) => {
|
|
80
80
|
if (!t)
|
|
81
81
|
return [];
|
|
82
|
-
const i = [...t],
|
|
83
|
-
return
|
|
82
|
+
const i = [...t], a = i.find((r) => r.id === o);
|
|
83
|
+
return a && (a.clicked = n), i;
|
|
84
84
|
});
|
|
85
|
-
},
|
|
86
|
-
if (!
|
|
85
|
+
}, C = async () => {
|
|
86
|
+
if (!d)
|
|
87
87
|
return;
|
|
88
|
-
const
|
|
89
|
-
n.length !== 0 && (
|
|
88
|
+
const o = (/* @__PURE__ */ new Date()).toISOString(), n = d.filter((t) => !t.opened || !t.seen).map((t) => t.id);
|
|
89
|
+
n.length !== 0 && (s(
|
|
90
90
|
c.apiURL,
|
|
91
91
|
"PATCH",
|
|
92
92
|
"notifications/INAPP_WEB",
|
|
@@ -95,21 +95,21 @@ const y = x(
|
|
|
95
95
|
e.hashedUserId,
|
|
96
96
|
{
|
|
97
97
|
trackingIds: n,
|
|
98
|
-
opened:
|
|
98
|
+
opened: o
|
|
99
99
|
}
|
|
100
100
|
), u((t) => {
|
|
101
101
|
if (!t)
|
|
102
102
|
return [];
|
|
103
103
|
const i = [...t];
|
|
104
|
-
return i.filter((
|
|
105
|
-
|
|
104
|
+
return i.filter((a) => n.includes(a.id)).forEach((a) => {
|
|
105
|
+
a.opened = o, a.seen = !0;
|
|
106
106
|
}), i;
|
|
107
107
|
}));
|
|
108
|
-
},
|
|
109
|
-
if (!
|
|
108
|
+
}, O = async (o) => {
|
|
109
|
+
if (!d)
|
|
110
110
|
return;
|
|
111
|
-
const n = (/* @__PURE__ */ new Date()).toISOString(), t =
|
|
112
|
-
t.length !== 0 && (
|
|
111
|
+
const n = (/* @__PURE__ */ new Date()).toISOString(), t = d.filter((i) => !i.archived && (o === "ALL" || o.includes(i.id))).map((i) => i.id);
|
|
112
|
+
t.length !== 0 && (s(
|
|
113
113
|
c.apiURL,
|
|
114
114
|
"PATCH",
|
|
115
115
|
"notifications/INAPP_WEB",
|
|
@@ -123,13 +123,13 @@ const y = x(
|
|
|
123
123
|
), u((i) => {
|
|
124
124
|
if (!i)
|
|
125
125
|
return [];
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
}),
|
|
126
|
+
const a = [...i];
|
|
127
|
+
return a.filter((r) => t.includes(r.id)).forEach((r) => {
|
|
128
|
+
r.archived = n;
|
|
129
|
+
}), a;
|
|
130
130
|
}));
|
|
131
|
-
},
|
|
132
|
-
|
|
131
|
+
}, D = (o, n, t, i) => {
|
|
132
|
+
s(
|
|
133
133
|
c.apiURL,
|
|
134
134
|
"POST",
|
|
135
135
|
"preferences",
|
|
@@ -138,34 +138,34 @@ const y = x(
|
|
|
138
138
|
e.hashedUserId,
|
|
139
139
|
[
|
|
140
140
|
{
|
|
141
|
-
notificationId:
|
|
141
|
+
notificationId: o,
|
|
142
142
|
subNotificationId: i,
|
|
143
143
|
channel: n,
|
|
144
144
|
delivery: t
|
|
145
145
|
}
|
|
146
146
|
]
|
|
147
147
|
).then(() => {
|
|
148
|
-
|
|
148
|
+
s(
|
|
149
149
|
c.apiURL,
|
|
150
150
|
"GET",
|
|
151
151
|
"preferences",
|
|
152
152
|
e.clientId,
|
|
153
153
|
e.userId,
|
|
154
154
|
e.hashedUserId
|
|
155
|
-
).then((
|
|
156
|
-
|
|
155
|
+
).then((a) => {
|
|
156
|
+
w(a);
|
|
157
157
|
});
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
160
|
+
y(() => {
|
|
161
|
+
P(!0);
|
|
162
|
+
const o = new WebSocket(
|
|
163
163
|
c.hashedUserId ? `${c.wsURL}?userId=${c.userId}&envId=${c.clientId}&userIdHash=${c.hashedUserId}` : `${c.wsURL}?userId=${c.userId}&envId=${c.clientId}`
|
|
164
164
|
);
|
|
165
|
-
|
|
165
|
+
o.onmessage = (n) => {
|
|
166
166
|
const t = JSON.parse(n.data);
|
|
167
|
-
!t || !t.route || t.route === "inapp_web/new_notifications" &&
|
|
168
|
-
},
|
|
167
|
+
!t || !t.route || t.route === "inapp_web/new_notifications" && A(t.payload.notifications);
|
|
168
|
+
}, s(
|
|
169
169
|
c.apiURL,
|
|
170
170
|
"GET",
|
|
171
171
|
"preferences",
|
|
@@ -173,24 +173,30 @@ const y = x(
|
|
|
173
173
|
e.userId,
|
|
174
174
|
e.hashedUserId
|
|
175
175
|
).then((n) => {
|
|
176
|
-
|
|
176
|
+
w(n);
|
|
177
177
|
});
|
|
178
178
|
}, []);
|
|
179
|
-
const
|
|
180
|
-
notifications:
|
|
181
|
-
preferences:
|
|
182
|
-
loadNotifications:
|
|
183
|
-
markAsOpened:
|
|
184
|
-
markAsArchived:
|
|
179
|
+
const H = {
|
|
180
|
+
notifications: d,
|
|
181
|
+
preferences: N,
|
|
182
|
+
loadNotifications: P,
|
|
183
|
+
markAsOpened: C,
|
|
184
|
+
markAsArchived: O,
|
|
185
185
|
markAsClicked: R,
|
|
186
|
-
updateDelivery:
|
|
186
|
+
updateDelivery: D
|
|
187
187
|
};
|
|
188
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ W(g.Provider, { value: H, children: e.children });
|
|
189
|
+
}, Y = () => {
|
|
190
|
+
const e = v(g);
|
|
191
|
+
if (!e)
|
|
192
|
+
throw new Error("useMyContext must be used within a MyProvider");
|
|
193
|
+
return e;
|
|
189
194
|
};
|
|
195
|
+
b.useNotificationAPIContext = Y;
|
|
190
196
|
export {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
B as Channels,
|
|
198
|
+
$ as DeliveryOptions,
|
|
199
|
+
q as NOTIFICATION_ACTIONS,
|
|
200
|
+
g as NotificationAPIContext,
|
|
201
|
+
b as NotificationAPIProvider
|
|
196
202
|
};
|
package/dist/interface.d.ts
CHANGED