@knocklabs/react-core 0.2.13 → 0.2.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/CHANGELOG.md +6 -0
- package/dist/cjs/modules/feed/hooks/useNotifications.js +1 -1
- package/dist/cjs/modules/feed/hooks/useNotifications.js.map +1 -1
- package/dist/esm/modules/feed/hooks/useNotifications.mjs +8 -9
- package/dist/esm/modules/feed/hooks/useNotifications.mjs.map +1 -1
- package/dist/types/modules/feed/hooks/useNotifications.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/modules/feed/hooks/useNotifications.ts +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const c=require("react");function i(t,s,e={}){const r=c.useRef();return c.useMemo(()=>(r.current&&r.current.dispose(),r.current=t.feeds.initialize(s,e),r.current.listenForUpdates(),r.current.store.subscribe(n=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.store.setState(n)}),r.current),[t,s,e.source,e.tenant,e.has_tenant,e.archived])}module.exports=i;
|
|
2
2
|
//# sourceMappingURL=useNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef
|
|
1
|
+
{"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n feedClientRef.current = knock.feeds.initialize(feedChannelId, options);\n feedClientRef.current.listenForUpdates();\n feedClientRef.current.store.subscribe((t) =>\n feedClientRef?.current?.store.setState(t),\n );\n\n return feedClientRef.current;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","current","dispose","feeds","initialize","listenForUpdates","store","subscribe","t","setState","source","tenant","has_tenant","archived"],"mappings":"sCAGA,SAASA,EACPC,EACAC,EACAC,EAA6B,CAAA,EAC7B,CACA,MAAMC,EAAgBC,EAAAA,SAEtB,OAAOC,UAAQ,KACTF,EAAcG,SAChBH,EAAcG,QAAQC,UAGxBJ,EAAcG,QAAUN,EAAMQ,MAAMC,WAAWR,EAAeC,CAAO,EACrEC,EAAcG,QAAQI,mBACRJ,EAAAA,QAAQK,MAAMC,UAAWC,GAAAA,OACrCV,OAAAA,EAAAA,GAAAA,YAAAA,EAAeG,UAAfH,YAAAA,EAAwBQ,MAAMG,SAASD,GACzC,EAEOV,EAAcG,SACpB,CACDN,EACAC,EACAC,EAAQa,OACRb,EAAQc,OACRd,EAAQe,WACRf,EAAQgB,QAAQ,CACjB,CACH"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}, [i, n, e.source, e.tenant, e.has_tenant, e.archived]);
|
|
1
|
+
import { useRef as n, useMemo as a } from "react";
|
|
2
|
+
function f(t, u, e = {}) {
|
|
3
|
+
const r = n();
|
|
4
|
+
return a(() => (r.current && r.current.dispose(), r.current = t.feeds.initialize(u, e), r.current.listenForUpdates(), r.current.store.subscribe((c) => {
|
|
5
|
+
var s;
|
|
6
|
+
return (s = r == null ? void 0 : r.current) == null ? void 0 : s.store.setState(c);
|
|
7
|
+
}), r.current), [t, u, e.source, e.tenant, e.has_tenant, e.archived]);
|
|
9
8
|
}
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
f as default
|
|
12
11
|
};
|
|
13
12
|
//# sourceMappingURL=useNotifications.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.mjs","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef
|
|
1
|
+
{"version":3,"file":"useNotifications.mjs","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n feedClientRef.current = knock.feeds.initialize(feedChannelId, options);\n feedClientRef.current.listenForUpdates();\n feedClientRef.current.store.subscribe((t) =>\n feedClientRef?.current?.store.setState(t),\n );\n\n return feedClientRef.current;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","current","dispose","feeds","initialize","listenForUpdates","store","subscribe","t","setState","source","tenant","has_tenant","archived"],"mappings":";AAGA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GAC7B;AACA,QAAMC,IAAgBC;AAEtB,SAAOC,EAAQ,OACTF,EAAcG,WAChBH,EAAcG,QAAQC,WAGxBJ,EAAcG,UAAUN,EAAMQ,MAAMC,WAAWR,GAAeC,CAAO,GACrEC,EAAcG,QAAQI,oBACRJ,EAAAA,QAAQK,MAAMC,UAAWC,CAAAA,MAAAA;;AACrCV,YAAAA,IAAAA,KAAAA,gBAAAA,EAAeG,YAAfH,gBAAAA,EAAwBQ,MAAMG,SAASD;AAAAA,GACzC,GAEOV,EAAcG,UACpB,CACDN,GACAC,GACAC,EAAQa,QACRb,EAAQc,QACRd,EAAQe,YACRf,EAAQgB,QAAQ,CACjB;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,
|
|
1
|
+
{"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,QAwBhC;AAED,eAAe,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@knocklabs/react-core",
|
|
3
3
|
"description": "A set of React components to build notification experiences powered by Knock",
|
|
4
4
|
"author": "@knocklabs",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.14",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.mjs",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Knock, { Feed, FeedClientOptions } from "@knocklabs/client";
|
|
2
|
-
import { useMemo, useRef
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
3
|
|
|
4
4
|
function useNotifications(
|
|
5
5
|
knock: Knock,
|
|
@@ -13,12 +13,13 @@ function useNotifications(
|
|
|
13
13
|
feedClientRef.current.dispose();
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
feedClientRef.current = knock.feeds.initialize(feedChannelId, options);
|
|
17
|
+
feedClientRef.current.listenForUpdates();
|
|
18
|
+
feedClientRef.current.store.subscribe((t) =>
|
|
19
|
+
feedClientRef?.current?.store.setState(t),
|
|
20
|
+
);
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
feedClientRef.current = feedClient;
|
|
20
|
-
|
|
21
|
-
return feedClient;
|
|
22
|
+
return feedClientRef.current;
|
|
22
23
|
}, [
|
|
23
24
|
knock,
|
|
24
25
|
feedChannelId,
|