stream-chat-react 12.8.0 → 12.8.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/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/Dialog/DialogManager.d.ts +8 -0
- package/dist/components/Dialog/DialogManager.js +42 -0
- package/dist/components/Dialog/hooks/useDialog.js +5 -1
- package/dist/experimental/index.browser.cjs +1 -1
- package/dist/experimental/index.browser.cjs.map +2 -2
- package/dist/experimental/index.node.cjs +1 -1
- package/dist/experimental/index.node.cjs.map +2 -2
- package/dist/index.browser.cjs +44 -2
- package/dist/index.browser.cjs.map +2 -2
- package/dist/index.node.cjs +44 -2
- package/dist/index.node.cjs.map +2 -2
- package/package.json +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -17976,6 +17976,7 @@ var DialogManager = class {
|
|
|
17976
17976
|
open: () => {
|
|
17977
17977
|
this.open({ id });
|
|
17978
17978
|
},
|
|
17979
|
+
removalTimeout: void 0,
|
|
17979
17980
|
remove: () => {
|
|
17980
17981
|
this.remove(id);
|
|
17981
17982
|
},
|
|
@@ -17988,6 +17989,21 @@ var DialogManager = class {
|
|
|
17988
17989
|
...{ dialogsById: { ...current.dialogsById, [id]: dialog } }
|
|
17989
17990
|
}));
|
|
17990
17991
|
}
|
|
17992
|
+
if (dialog.removalTimeout) {
|
|
17993
|
+
clearTimeout(dialog.removalTimeout);
|
|
17994
|
+
this.state.next((current) => ({
|
|
17995
|
+
...current,
|
|
17996
|
+
...{
|
|
17997
|
+
dialogsById: {
|
|
17998
|
+
...current.dialogsById,
|
|
17999
|
+
[id]: {
|
|
18000
|
+
...dialog,
|
|
18001
|
+
removalTimeout: void 0
|
|
18002
|
+
}
|
|
18003
|
+
}
|
|
18004
|
+
}
|
|
18005
|
+
}));
|
|
18006
|
+
}
|
|
17991
18007
|
return dialog;
|
|
17992
18008
|
}
|
|
17993
18009
|
open(params, closeRest) {
|
|
@@ -18023,6 +18039,9 @@ var DialogManager = class {
|
|
|
18023
18039
|
const state = this.state.getLatestValue();
|
|
18024
18040
|
const dialog = state.dialogsById[id];
|
|
18025
18041
|
if (!dialog) return;
|
|
18042
|
+
if (dialog.removalTimeout) {
|
|
18043
|
+
clearTimeout(dialog.removalTimeout);
|
|
18044
|
+
}
|
|
18026
18045
|
this.state.next((current) => {
|
|
18027
18046
|
const newDialogs = { ...current.dialogsById };
|
|
18028
18047
|
delete newDialogs[id];
|
|
@@ -18032,6 +18051,29 @@ var DialogManager = class {
|
|
|
18032
18051
|
};
|
|
18033
18052
|
});
|
|
18034
18053
|
}
|
|
18054
|
+
/**
|
|
18055
|
+
* Marks the dialog state as unused. If the dialog id is referenced again quickly,
|
|
18056
|
+
* the state will not be removed. Otherwise, the state will be removed after
|
|
18057
|
+
* a short timeout.
|
|
18058
|
+
*/
|
|
18059
|
+
markForRemoval(id) {
|
|
18060
|
+
const dialog = this.state.getLatestValue().dialogsById[id];
|
|
18061
|
+
if (!dialog) {
|
|
18062
|
+
return;
|
|
18063
|
+
}
|
|
18064
|
+
this.state.next((current) => ({
|
|
18065
|
+
...current,
|
|
18066
|
+
dialogsById: {
|
|
18067
|
+
...current.dialogsById,
|
|
18068
|
+
[id]: {
|
|
18069
|
+
...dialog,
|
|
18070
|
+
removalTimeout: setTimeout(() => {
|
|
18071
|
+
this.remove(id);
|
|
18072
|
+
}, 16)
|
|
18073
|
+
}
|
|
18074
|
+
}
|
|
18075
|
+
}));
|
|
18076
|
+
}
|
|
18035
18077
|
};
|
|
18036
18078
|
|
|
18037
18079
|
// src/components/Dialog/DialogPortal.tsx
|
|
@@ -18060,7 +18102,7 @@ var useDialog = ({ id }) => {
|
|
|
18060
18102
|
const { dialogManager } = useDialogManager();
|
|
18061
18103
|
(0, import_react7.useEffect)(
|
|
18062
18104
|
() => () => {
|
|
18063
|
-
dialogManager.
|
|
18105
|
+
dialogManager.markForRemoval(id);
|
|
18064
18106
|
},
|
|
18065
18107
|
[dialogManager, id]
|
|
18066
18108
|
);
|
|
@@ -50750,7 +50792,7 @@ var useChat = ({
|
|
|
50750
50792
|
if (!client) return;
|
|
50751
50793
|
const userAgent = client.getUserAgent();
|
|
50752
50794
|
if (!userAgent.includes("stream-chat-react")) {
|
|
50753
|
-
client.setUserAgent(`stream-chat-react-12.8.
|
|
50795
|
+
client.setUserAgent(`stream-chat-react-12.8.1-${userAgent}`);
|
|
50754
50796
|
}
|
|
50755
50797
|
client.threads.registerSubscriptions();
|
|
50756
50798
|
client.polls.registerSubscriptions();
|