stream-chat-react 13.13.3 → 13.13.5
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/AIStateIndicator/hooks/useAIState.d.ts +1 -0
- package/dist/components/AIStateIndicator/hooks/useAIState.js +8 -0
- package/dist/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/Message/StreamedMessageText.js +9 -3
- package/dist/components/Message/hooks/useMessageTextStreaming.d.ts +2 -1
- package/dist/components/Message/hooks/useMessageTextStreaming.js +7 -1
- package/dist/components/MessageList/hooks/useMarkRead.js +2 -0
- package/dist/index.browser.cjs +23 -3
- package/dist/index.browser.cjs.map +2 -2
- package/dist/index.node.cjs +23 -3
- package/dist/index.node.cjs.map +2 -2
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -729,6 +729,7 @@ var AIStates = {
|
|
|
729
729
|
ExternalSources: "AI_STATE_EXTERNAL_SOURCES",
|
|
730
730
|
Generating: "AI_STATE_GENERATING",
|
|
731
731
|
Idle: "AI_STATE_IDLE",
|
|
732
|
+
Stop: "AI_STATE_STOP",
|
|
732
733
|
Thinking: "AI_STATE_THINKING"
|
|
733
734
|
};
|
|
734
735
|
var useAIState = (channel) => {
|
|
@@ -750,9 +751,16 @@ var useAIState = (channel) => {
|
|
|
750
751
|
setAiState(AIStates.Idle);
|
|
751
752
|
}
|
|
752
753
|
});
|
|
754
|
+
const indicatorStoppedListener = channel.on("ai_indicator.stop", (event) => {
|
|
755
|
+
const { cid } = event;
|
|
756
|
+
if (channel.cid === cid) {
|
|
757
|
+
setAiState(AIStates.Stop);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
753
760
|
return () => {
|
|
754
761
|
indicatorChangedListener.unsubscribe();
|
|
755
762
|
indicatorClearedListener.unsubscribe();
|
|
763
|
+
indicatorStoppedListener.unsubscribe();
|
|
756
764
|
};
|
|
757
765
|
}, [channel]);
|
|
758
766
|
return { aiState };
|
|
@@ -18797,6 +18805,7 @@ var useMessageTextStreaming = ({
|
|
|
18797
18805
|
const interval = setInterval(() => {
|
|
18798
18806
|
if (!text8 || textCursor.current >= textLength) {
|
|
18799
18807
|
clearInterval(interval);
|
|
18808
|
+
return;
|
|
18800
18809
|
}
|
|
18801
18810
|
const newCursorValue = textCursor.current + renderingLetterCount;
|
|
18802
18811
|
const newText = text8.substring(0, newCursorValue);
|
|
@@ -18807,7 +18816,11 @@ var useMessageTextStreaming = ({
|
|
|
18807
18816
|
clearInterval(interval);
|
|
18808
18817
|
};
|
|
18809
18818
|
}, [streamingLetterIntervalMs, renderingLetterCount, text8]);
|
|
18810
|
-
|
|
18819
|
+
const skipAnimation = useStableCallback(() => {
|
|
18820
|
+
textCursor.current = text8.length;
|
|
18821
|
+
setStreamedMessageText(text8);
|
|
18822
|
+
});
|
|
18823
|
+
return { skipAnimation, streamedMessageText };
|
|
18811
18824
|
};
|
|
18812
18825
|
|
|
18813
18826
|
// src/components/Message/hooks/useMessageReminder.ts
|
|
@@ -25947,13 +25960,19 @@ var StreamedMessageText = (props) => {
|
|
|
25947
25960
|
streamingLetterIntervalMs
|
|
25948
25961
|
} = props;
|
|
25949
25962
|
const { message: messageFromContext } = useMessageContext("StreamedMessageText");
|
|
25963
|
+
const { channel } = useChannelStateContext();
|
|
25950
25964
|
const message = messageFromProps || messageFromContext;
|
|
25951
25965
|
const { text: text8 = "" } = message;
|
|
25952
|
-
const { streamedMessageText } = useMessageTextStreaming({
|
|
25966
|
+
const { skipAnimation, streamedMessageText } = useMessageTextStreaming({
|
|
25953
25967
|
renderingLetterCount,
|
|
25954
25968
|
streamingLetterIntervalMs,
|
|
25955
25969
|
text: text8
|
|
25956
25970
|
});
|
|
25971
|
+
(0, import_react160.useEffect)(() => {
|
|
25972
|
+
channel?.on("ai_indicator.stop", () => {
|
|
25973
|
+
skipAnimation();
|
|
25974
|
+
});
|
|
25975
|
+
}, [channel, skipAnimation]);
|
|
25957
25976
|
return /* @__PURE__ */ import_react160.default.createElement(
|
|
25958
25977
|
MessageText,
|
|
25959
25978
|
{
|
|
@@ -30492,6 +30511,7 @@ var useMarkRead = ({
|
|
|
30492
30511
|
const { markRead, setChannelUnreadUiState } = useChannelActionContext("useMarkRead");
|
|
30493
30512
|
const { channel } = useChannelStateContext("useMarkRead");
|
|
30494
30513
|
(0, import_react173.useEffect)(() => {
|
|
30514
|
+
if (!channel.getConfig()?.read_events) return;
|
|
30495
30515
|
const shouldMarkRead = () => !document.hidden && !wasMarkedUnread && !messageListIsThread && isMessageListScrolledToBottom && client.user?.id && !hasReadLastMessage(channel, client.user.id);
|
|
30496
30516
|
const onVisibilityChange = () => {
|
|
30497
30517
|
if (shouldMarkRead()) markRead();
|
|
@@ -39269,7 +39289,7 @@ var useChat = ({
|
|
|
39269
39289
|
};
|
|
39270
39290
|
(0, import_react289.useEffect)(() => {
|
|
39271
39291
|
if (!client) return;
|
|
39272
|
-
const version = "13.13.
|
|
39292
|
+
const version = "13.13.5";
|
|
39273
39293
|
const userAgent = client.getUserAgent();
|
|
39274
39294
|
if (!userAgent.includes("stream-chat-react")) {
|
|
39275
39295
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|