@droppii-org/chat-sdk 0.1.40 → 0.1.42
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/biz-inbox/BizThreadList.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadList.js +2 -25
- package/dist/hooks/biz/useBizActiveConversation.d.ts.map +1 -1
- package/dist/hooks/biz/useBizActiveConversation.js +4 -27
- package/dist/hooks/message/useMessage.d.ts.map +1 -1
- package/dist/hooks/message/useMessage.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/bizMessage.d.ts.map +1 -1
- package/dist/utils/bizMessage.js +3 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizThreadList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadList.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAOvF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC1D;AAYD,QAAA,MAAM,aAAa,GAAI,oFAOpB,kBAAkB,4CAkFpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import { Empty, Spin } from "antd";
|
|
6
6
|
import InfiniteScroll from "react-infinite-scroll-component";
|
|
7
|
-
import { DChatSDK } from "../../constants/sdk";
|
|
8
7
|
import useBizConversationStore from "../../store/bizConversation";
|
|
9
8
|
import useConversationStore from "../../store/conversation";
|
|
10
9
|
import { buildBizSdkConversation } from "../../utils/bizConversation";
|
|
@@ -16,38 +15,16 @@ const BizThreadList = ({ items, isLoading, isFetchingNextPage, hasNextPage, onLo
|
|
|
16
15
|
const router = useRouter();
|
|
17
16
|
const pathname = usePathname();
|
|
18
17
|
const searchParams = useSearchParams();
|
|
19
|
-
const sdkConversations = useBizConversationStore((state) => state.sdkConversations);
|
|
20
18
|
const selectConversation = useBizConversationStore((state) => state.selectConversation);
|
|
21
19
|
const setConversationData = useConversationStore((state) => state.setConversationData);
|
|
22
20
|
const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
|
|
23
|
-
const syncSdkConversation = (item) => {
|
|
24
|
-
const conversationId = item.conversationId;
|
|
25
|
-
setSelectedConversationId(conversationId);
|
|
26
|
-
const cachedConversation = sdkConversations[conversationId];
|
|
27
|
-
if (cachedConversation) {
|
|
28
|
-
setConversationData(cachedConversation);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
setConversationData(buildBizSdkConversation(item));
|
|
32
|
-
}
|
|
33
|
-
DChatSDK.getMultipleConversation([conversationId])
|
|
34
|
-
.then((res) => {
|
|
35
|
-
if (res.data.length > 0 &&
|
|
36
|
-
useConversationStore.getState().selectedConversationId ===
|
|
37
|
-
conversationId) {
|
|
38
|
-
setConversationData(res.data[0]);
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
.catch((error) => {
|
|
42
|
-
console.error("getMultipleConversation", error);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
21
|
const handleSelectThread = (item) => {
|
|
46
22
|
const newSearchParams = new URLSearchParams(searchParams);
|
|
47
23
|
newSearchParams.set("threadId", item.conversationId);
|
|
48
24
|
router.push(`${pathname}?${newSearchParams.toString()}`);
|
|
49
25
|
selectConversation(item);
|
|
50
|
-
|
|
26
|
+
setSelectedConversationId(item.conversationId);
|
|
27
|
+
setConversationData(buildBizSdkConversation(item));
|
|
51
28
|
onSelectThread === null || onSelectThread === void 0 ? void 0 : onSelectThread(item);
|
|
52
29
|
};
|
|
53
30
|
const handleEndReached = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBizActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBizActiveConversation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBizActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBizActiveConversation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,eAAO,MAAM,wBAAwB,GACnC,mBAAmB,uBAAuB,EAAE,SAkD7C,CAAC"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { useSearchParams } from "next/navigation";
|
|
3
|
-
import { DChatSDK } from "../../constants/sdk";
|
|
4
|
-
import { useChatContext } from "../../context/ChatContext";
|
|
5
|
-
import { ConnectStatus } from "../../types/chat";
|
|
6
3
|
import useBizConversationStore from "../../store/bizConversation";
|
|
7
4
|
import useConversationStore from "../../store/conversation";
|
|
8
5
|
import { buildBizSdkConversation } from "../../utils/bizConversation";
|
|
9
6
|
export const useBizActiveConversation = (conversationItems) => {
|
|
10
7
|
const searchParams = useSearchParams();
|
|
11
8
|
const threadId = searchParams.get("threadId");
|
|
12
|
-
const { connectStatus } = useChatContext();
|
|
13
|
-
const sdkConversations = useBizConversationStore((state) => state.sdkConversations);
|
|
14
9
|
const selectConversation = useBizConversationStore((state) => state.selectConversation);
|
|
15
10
|
const clearBizConversation = useBizConversationStore((state) => state.clearSelectedConversation);
|
|
16
11
|
const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
|
|
@@ -24,34 +19,16 @@ export const useBizActiveConversation = (conversationItems) => {
|
|
|
24
19
|
}
|
|
25
20
|
setSelectedConversationId(threadId);
|
|
26
21
|
const matchedThread = conversationItems.find((item) => item.conversationId === threadId);
|
|
22
|
+
if (!matchedThread)
|
|
23
|
+
return;
|
|
27
24
|
const currentBizData = useBizConversationStore.getState().conversationData;
|
|
28
|
-
if ((currentBizData === null || currentBizData === void 0 ? void 0 : currentBizData.conversationId) !== threadId
|
|
25
|
+
if ((currentBizData === null || currentBizData === void 0 ? void 0 : currentBizData.conversationId) !== threadId) {
|
|
29
26
|
selectConversation(matchedThread);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
const cachedConversation = sdkConversations[threadId];
|
|
34
|
-
if (cachedConversation) {
|
|
35
|
-
setConversationData(cachedConversation);
|
|
36
|
-
}
|
|
37
|
-
else if (matchedThread) {
|
|
38
|
-
setConversationData(buildBizSdkConversation(matchedThread));
|
|
39
|
-
}
|
|
40
|
-
DChatSDK.getMultipleConversation([threadId])
|
|
41
|
-
.then((res) => {
|
|
42
|
-
if (res.data.length > 0 &&
|
|
43
|
-
useConversationStore.getState().selectedConversationId === threadId) {
|
|
44
|
-
setConversationData(res.data[0]);
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
.catch((error) => {
|
|
48
|
-
console.error("getMultipleConversation", error);
|
|
49
|
-
});
|
|
28
|
+
setConversationData(buildBizSdkConversation(matchedThread));
|
|
50
29
|
}, [
|
|
51
30
|
threadId,
|
|
52
31
|
conversationItems,
|
|
53
|
-
sdkConversations,
|
|
54
|
-
connectStatus,
|
|
55
32
|
selectConversation,
|
|
56
33
|
clearBizConversation,
|
|
57
34
|
clearSdkConversation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAUjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc;;;;;
|
|
1
|
+
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAUjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc;;;;;qBAeO,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CA0QnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}
|
|
@@ -7,7 +7,7 @@ import emitter, { emit } from "../../utils/events";
|
|
|
7
7
|
import isEmpty from "lodash/isEmpty";
|
|
8
8
|
import { useChatContext } from "../../context/ChatContext";
|
|
9
9
|
import useAuthStore from "../../store/auth";
|
|
10
|
-
import { ConnectStatus } from "../../types/chat";
|
|
10
|
+
import { ConnectStatus, SyncStatus } from "../../types/chat";
|
|
11
11
|
export const visibleTypeMessage = [
|
|
12
12
|
MessageType.TextMessage,
|
|
13
13
|
MessageType.PictureMessage,
|
|
@@ -26,10 +26,11 @@ export const visibleTypeMessage = [
|
|
|
26
26
|
MessageType.LogTextMessage,
|
|
27
27
|
];
|
|
28
28
|
export const useMessage = (conversationId, searchClientMsgID, enabled = true) => {
|
|
29
|
-
const { connectStatus } = useChatContext();
|
|
29
|
+
const { connectStatus, syncStatus } = useChatContext();
|
|
30
30
|
const userID = useAuthStore((state) => state.userID);
|
|
31
31
|
const canLoad = enabled &&
|
|
32
32
|
connectStatus === ConnectStatus.Connected &&
|
|
33
|
+
syncStatus !== SyncStatus.Loading &&
|
|
33
34
|
!!conversationId &&
|
|
34
35
|
!!userID;
|
|
35
36
|
const [loadState, setLoadState] = useState({
|
|
@@ -151,7 +152,6 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
|
|
|
151
152
|
});
|
|
152
153
|
setTimeout(() => {
|
|
153
154
|
emit("CHAT_LIST_SCROLL_TO_MESSAGE", searchClientMsgID);
|
|
154
|
-
console.log("emit scroll to message");
|
|
155
155
|
}, 200);
|
|
156
156
|
}, {
|
|
157
157
|
manual: true,
|