@diffsome/react 1.2.8 → 1.2.9
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/index.js +7 -6
- package/dist/index.mjs +8 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2824,6 +2824,7 @@ var ChatBubble = ({
|
|
|
2824
2824
|
const [loading, setLoading] = (0, import_react24.useState)(false);
|
|
2825
2825
|
const [typing, setTyping] = (0, import_react24.useState)(false);
|
|
2826
2826
|
const [unreadCount, setUnreadCount] = (0, import_react24.useState)(0);
|
|
2827
|
+
const seenMessageIds = (0, import_react24.useRef)(/* @__PURE__ */ new Set());
|
|
2827
2828
|
const initChat = (0, import_react24.useCallback)(async () => {
|
|
2828
2829
|
if (conversationId) return;
|
|
2829
2830
|
setLoading(true);
|
|
@@ -2837,14 +2838,14 @@ var ChatBubble = ({
|
|
|
2837
2838
|
const conn = client.chat.connect(result.conversation_id);
|
|
2838
2839
|
setConnection(conn);
|
|
2839
2840
|
const existingMessages = await conn.getMessages();
|
|
2841
|
+
existingMessages.forEach((m) => seenMessageIds.current.add(m.id));
|
|
2840
2842
|
setMessages(existingMessages);
|
|
2841
2843
|
conn.onMessage((msg) => {
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
});
|
|
2844
|
+
if (seenMessageIds.current.has(msg.id)) {
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
seenMessageIds.current.add(msg.id);
|
|
2848
|
+
setMessages((prev) => [...prev, msg]);
|
|
2848
2849
|
if (!isOpen && msg.sender_type !== "visitor") {
|
|
2849
2850
|
setUnreadCount((c) => c + 1);
|
|
2850
2851
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2490,7 +2490,7 @@ function RichContent({
|
|
|
2490
2490
|
}
|
|
2491
2491
|
|
|
2492
2492
|
// src/components/chat/ChatBubble.tsx
|
|
2493
|
-
import { useState as useState22, useEffect as useEffect21, useCallback as useCallback22 } from "react";
|
|
2493
|
+
import { useState as useState22, useEffect as useEffect21, useCallback as useCallback22, useRef as useRef3 } from "react";
|
|
2494
2494
|
|
|
2495
2495
|
// src/components/chat/ChatWidget.tsx
|
|
2496
2496
|
import { useRef as useRef2, useEffect as useEffect20 } from "react";
|
|
@@ -2732,6 +2732,7 @@ var ChatBubble = ({
|
|
|
2732
2732
|
const [loading, setLoading] = useState22(false);
|
|
2733
2733
|
const [typing, setTyping] = useState22(false);
|
|
2734
2734
|
const [unreadCount, setUnreadCount] = useState22(0);
|
|
2735
|
+
const seenMessageIds = useRef3(/* @__PURE__ */ new Set());
|
|
2735
2736
|
const initChat = useCallback22(async () => {
|
|
2736
2737
|
if (conversationId) return;
|
|
2737
2738
|
setLoading(true);
|
|
@@ -2745,14 +2746,14 @@ var ChatBubble = ({
|
|
|
2745
2746
|
const conn = client.chat.connect(result.conversation_id);
|
|
2746
2747
|
setConnection(conn);
|
|
2747
2748
|
const existingMessages = await conn.getMessages();
|
|
2749
|
+
existingMessages.forEach((m) => seenMessageIds.current.add(m.id));
|
|
2748
2750
|
setMessages(existingMessages);
|
|
2749
2751
|
conn.onMessage((msg) => {
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
});
|
|
2752
|
+
if (seenMessageIds.current.has(msg.id)) {
|
|
2753
|
+
return;
|
|
2754
|
+
}
|
|
2755
|
+
seenMessageIds.current.add(msg.id);
|
|
2756
|
+
setMessages((prev) => [...prev, msg]);
|
|
2756
2757
|
if (!isOpen && msg.sender_type !== "visitor") {
|
|
2757
2758
|
setUnreadCount((c) => c + 1);
|
|
2758
2759
|
}
|