@droppii-org/chat-sdk 0.6.47 → 0.6.48
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnreadMessageIndicator.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useUnreadMessageIndicator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAUhE,eAAO,MAAM,8BAA8B,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useUnreadMessageIndicator.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useUnreadMessageIndicator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAUhE,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAoEnD,UAAU,+BAA+B;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,WAAW,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,qDAIvC,+BAA+B;;;;;;CA8FjC,CAAC"}
|
|
@@ -32,6 +32,12 @@ async function settleWithinTimeout(request, fallback) {
|
|
|
32
32
|
clearTimeout(timer);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
// A viewer outside the conversation (an agent browsing a shared support thread)
|
|
36
|
+
// has no local copy, so mark-as-read fails and the server keeps it all unread.
|
|
37
|
+
const hasLocalConversation = (conversationId) => settleWithinTimeout(async () => {
|
|
38
|
+
const { data } = await DChatSDK.getMultipleConversation([conversationId]);
|
|
39
|
+
return !!(data === null || data === void 0 ? void 0 : data.some((item) => item.conversationID === conversationId));
|
|
40
|
+
}, false);
|
|
35
41
|
const fetchFirstUnreadMessage = (conversationId) => settleWithinTimeout(async () => {
|
|
36
42
|
var _a;
|
|
37
43
|
const { data } = await DChatSDK.getFirstUnreadMessage(conversationId);
|
|
@@ -93,7 +99,9 @@ export const useUnreadMessageIndicator = ({ conversationId = "", searchClientMsg
|
|
|
93
99
|
const targetPromise = openTargetClientMsgID
|
|
94
100
|
? fetchMessage(conversationId, openTargetClientMsgID)
|
|
95
101
|
: Promise.resolve(undefined);
|
|
96
|
-
const firstUnreadMessage = await
|
|
102
|
+
const firstUnreadMessage = (await hasLocalConversation(conversationId))
|
|
103
|
+
? await fetchFirstUnreadMessage(conversationId)
|
|
104
|
+
: null;
|
|
97
105
|
const openTarget = await targetPromise;
|
|
98
106
|
if (requestId !== requestIdRef.current)
|
|
99
107
|
return;
|