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.node.cjs
CHANGED
|
@@ -20673,6 +20673,7 @@ var DialogManager = class {
|
|
|
20673
20673
|
open: () => {
|
|
20674
20674
|
this.open({ id });
|
|
20675
20675
|
},
|
|
20676
|
+
removalTimeout: void 0,
|
|
20676
20677
|
remove: () => {
|
|
20677
20678
|
this.remove(id);
|
|
20678
20679
|
},
|
|
@@ -20685,6 +20686,21 @@ var DialogManager = class {
|
|
|
20685
20686
|
...{ dialogsById: { ...current.dialogsById, [id]: dialog } }
|
|
20686
20687
|
}));
|
|
20687
20688
|
}
|
|
20689
|
+
if (dialog.removalTimeout) {
|
|
20690
|
+
clearTimeout(dialog.removalTimeout);
|
|
20691
|
+
this.state.next((current) => ({
|
|
20692
|
+
...current,
|
|
20693
|
+
...{
|
|
20694
|
+
dialogsById: {
|
|
20695
|
+
...current.dialogsById,
|
|
20696
|
+
[id]: {
|
|
20697
|
+
...dialog,
|
|
20698
|
+
removalTimeout: void 0
|
|
20699
|
+
}
|
|
20700
|
+
}
|
|
20701
|
+
}
|
|
20702
|
+
}));
|
|
20703
|
+
}
|
|
20688
20704
|
return dialog;
|
|
20689
20705
|
}
|
|
20690
20706
|
open(params, closeRest) {
|
|
@@ -20720,6 +20736,9 @@ var DialogManager = class {
|
|
|
20720
20736
|
const state = this.state.getLatestValue();
|
|
20721
20737
|
const dialog = state.dialogsById[id];
|
|
20722
20738
|
if (!dialog) return;
|
|
20739
|
+
if (dialog.removalTimeout) {
|
|
20740
|
+
clearTimeout(dialog.removalTimeout);
|
|
20741
|
+
}
|
|
20723
20742
|
this.state.next((current) => {
|
|
20724
20743
|
const newDialogs = { ...current.dialogsById };
|
|
20725
20744
|
delete newDialogs[id];
|
|
@@ -20729,6 +20748,29 @@ var DialogManager = class {
|
|
|
20729
20748
|
};
|
|
20730
20749
|
});
|
|
20731
20750
|
}
|
|
20751
|
+
/**
|
|
20752
|
+
* Marks the dialog state as unused. If the dialog id is referenced again quickly,
|
|
20753
|
+
* the state will not be removed. Otherwise, the state will be removed after
|
|
20754
|
+
* a short timeout.
|
|
20755
|
+
*/
|
|
20756
|
+
markForRemoval(id) {
|
|
20757
|
+
const dialog = this.state.getLatestValue().dialogsById[id];
|
|
20758
|
+
if (!dialog) {
|
|
20759
|
+
return;
|
|
20760
|
+
}
|
|
20761
|
+
this.state.next((current) => ({
|
|
20762
|
+
...current,
|
|
20763
|
+
dialogsById: {
|
|
20764
|
+
...current.dialogsById,
|
|
20765
|
+
[id]: {
|
|
20766
|
+
...dialog,
|
|
20767
|
+
removalTimeout: setTimeout(() => {
|
|
20768
|
+
this.remove(id);
|
|
20769
|
+
}, 16)
|
|
20770
|
+
}
|
|
20771
|
+
}
|
|
20772
|
+
}));
|
|
20773
|
+
}
|
|
20732
20774
|
};
|
|
20733
20775
|
|
|
20734
20776
|
// src/components/Dialog/DialogPortal.tsx
|
|
@@ -20757,7 +20799,7 @@ var useDialog = ({ id }) => {
|
|
|
20757
20799
|
const { dialogManager } = useDialogManager();
|
|
20758
20800
|
(0, import_react7.useEffect)(
|
|
20759
20801
|
() => () => {
|
|
20760
|
-
dialogManager.
|
|
20802
|
+
dialogManager.markForRemoval(id);
|
|
20761
20803
|
},
|
|
20762
20804
|
[dialogManager, id]
|
|
20763
20805
|
);
|
|
@@ -55317,7 +55359,7 @@ var useChat = ({
|
|
|
55317
55359
|
if (!client) return;
|
|
55318
55360
|
const userAgent = client.getUserAgent();
|
|
55319
55361
|
if (!userAgent.includes("stream-chat-react")) {
|
|
55320
|
-
client.setUserAgent(`stream-chat-react-12.8.
|
|
55362
|
+
client.setUserAgent(`stream-chat-react-12.8.1-${userAgent}`);
|
|
55321
55363
|
}
|
|
55322
55364
|
client.threads.registerSubscriptions();
|
|
55323
55365
|
client.polls.registerSubscriptions();
|