@droppii-org/chat-sdk 0.0.35 → 0.0.36
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":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQ7E,eAAO,MAAM,kBAAkB,eAa9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,gBAAgB,MAAM,EACtB,oBAAoB,MAAM;;;;;qBAML,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;
|
|
1
|
+
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQ7E,eAAO,MAAM,kBAAkB,eAa9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,gBAAgB,MAAM,EACtB,oBAAoB,MAAM;;;;;qBAML,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CAsMnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAElC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAiBhB,CAAC"}
|
|
@@ -42,10 +42,11 @@ export const useMessage = (conversationId, searchClientMsgID) => {
|
|
|
42
42
|
if (conversationId !== reqConversationID)
|
|
43
43
|
return;
|
|
44
44
|
setTimeout(() => setLoadState((preState) => {
|
|
45
|
-
|
|
45
|
+
let messageList = [
|
|
46
46
|
...(loadMore ? preState.messageList : []),
|
|
47
47
|
...data.messageList.toReversed(),
|
|
48
48
|
];
|
|
49
|
+
messageList = removeDuplicateMessages(messageList);
|
|
49
50
|
return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreOld: !data.isEnd, messageList });
|
|
50
51
|
}));
|
|
51
52
|
}, {
|
|
@@ -65,10 +66,11 @@ export const useMessage = (conversationId, searchClientMsgID) => {
|
|
|
65
66
|
if (conversationId !== reqConversationID)
|
|
66
67
|
return;
|
|
67
68
|
setTimeout(() => setLoadState((preState) => {
|
|
68
|
-
|
|
69
|
+
let messageList = [
|
|
69
70
|
...data.messageList.toReversed(),
|
|
70
71
|
...(loadMore ? preState.messageList : []),
|
|
71
72
|
];
|
|
73
|
+
messageList = removeDuplicateMessages(messageList);
|
|
72
74
|
return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreNew: !data.isEnd, messageList });
|
|
73
75
|
}));
|
|
74
76
|
}, {
|
|
@@ -102,11 +104,12 @@ export const useMessage = (conversationId, searchClientMsgID) => {
|
|
|
102
104
|
return;
|
|
103
105
|
setTimeout(() => {
|
|
104
106
|
setLoadState((preState) => {
|
|
105
|
-
|
|
107
|
+
let messageList = [
|
|
106
108
|
...dataNext.messageList.toReversed(),
|
|
107
109
|
...currentMessages,
|
|
108
110
|
...dataPrev.messageList.toReversed(),
|
|
109
111
|
];
|
|
112
|
+
messageList = removeDuplicateMessages(messageList);
|
|
110
113
|
return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreOld: !dataPrev.isEnd, hasMoreNew: !dataNext.isEnd, messageList });
|
|
111
114
|
});
|
|
112
115
|
});
|
|
@@ -188,3 +191,13 @@ export const getVisibleNeighbor = (allMessages, current, direction) => {
|
|
|
188
191
|
}
|
|
189
192
|
return undefined;
|
|
190
193
|
};
|
|
194
|
+
const removeDuplicateMessages = (messages) => {
|
|
195
|
+
const seen = new Set();
|
|
196
|
+
return messages.filter((msg) => {
|
|
197
|
+
if (seen.has(msg.clientMsgID)) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
seen.add(msg.clientMsgID);
|
|
201
|
+
return true;
|
|
202
|
+
});
|
|
203
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/user/useAuth.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY;;
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/user/useAuth.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY;;CAyBxB,CAAC"}
|
|
@@ -7,6 +7,7 @@ export const useDChatAuth = () => {
|
|
|
7
7
|
const initAuthStore = useAuthStore((state) => state.initAuthStore);
|
|
8
8
|
const resetConversationStore = useConversationStore((state) => state.resetConversationStore);
|
|
9
9
|
const logout = async () => {
|
|
10
|
+
await Promise.resolve(DChatSDK.deleteAllMsgFromLocal());
|
|
10
11
|
await Promise.resolve(resetConversationStore());
|
|
11
12
|
await Promise.resolve(initAuthStore({
|
|
12
13
|
chatToken: "",
|