@droppii-org/chat-sdk 0.1.61 → 0.1.64
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/conversation-detail/ConversationMessageList.d.ts.map +1 -1
- package/dist/components/conversation-detail/ConversationMessageList.js +1 -1
- package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
- package/dist/hooks/global/useGlobalEvent.js +16 -0
- package/dist/hooks/message/useMessage.d.ts +1 -1
- package/dist/hooks/message/useMessage.d.ts.map +1 -1
- package/dist/hooks/message/useMessage.js +19 -8
- package/dist/store/conversation.d.ts.map +1 -1
- package/dist/store/conversation.js +10 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationMessageList.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkBzE,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED,QAAA,MAAM,uBAAuB,GAAI,gBAAgB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"ConversationMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationMessageList.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkBzE,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED,QAAA,MAAM,uBAAuB,GAAI,gBAAgB,4BAA4B,4CAsK5E,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -28,7 +28,7 @@ const ConversationMessageList = ({ bottomSlot }) => {
|
|
|
28
28
|
const setSearchClientMsgID = useConversationStore((state) => state.setSearchClientMsgID);
|
|
29
29
|
const conversationId = selectedConversationId || (conversation === null || conversation === void 0 ? void 0 : conversation.conversationID) || "";
|
|
30
30
|
const isGroupChat = conversation ? resolveIsGroupChat(conversation) : false;
|
|
31
|
-
const messageController = useMessage(conversationId, searchClientMsgID);
|
|
31
|
+
const messageController = useMessage(conversationId, searchClientMsgID, true, true);
|
|
32
32
|
const { scrollRef, loadMoreOldMessage, handleInfiniteScroll, scrollToBottomIfAtBottom, scrollToMessage, } = useMessageListScroll(Object.assign({ conversationId, userId: (user === null || user === void 0 ? void 0 : user.userID) || authUserID }, messageController));
|
|
33
33
|
const { loadState, moreOldLoading } = messageController;
|
|
34
34
|
const isMessageLoading = !conversationId || loadState.initLoading;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,cAAc,YAkV1B,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { DChatSDK } from "../../constants/sdk";
|
|
|
3
3
|
import { CbEvents, MessageType, SessionType, } from "@openim/wasm-client-sdk";
|
|
4
4
|
import { BusinessNotificationType, ConnectStatus, CustomType, SyncStatus, } from "../../types/chat";
|
|
5
5
|
import { pushNewMessage, updateOneMessage } from "../../hooks/message/useMessage";
|
|
6
|
+
import { fetchPinnedMessages } from "../../hooks/message/usePinnedMessages";
|
|
6
7
|
import { useChatContext } from "../../context/ChatContext";
|
|
7
8
|
import useConversationStore from "../../store/conversation";
|
|
8
9
|
import useAuthStore from "../../store/auth";
|
|
@@ -49,6 +50,19 @@ export const useGlobalEvent = () => {
|
|
|
49
50
|
},
|
|
50
51
|
});
|
|
51
52
|
};
|
|
53
|
+
const messagePinnedHandler = ({ data }) => {
|
|
54
|
+
updateOneMessage({
|
|
55
|
+
clientMsgID: data.clientMsgID,
|
|
56
|
+
isPinned: data.isPinned,
|
|
57
|
+
pinnedByUserID: data.operatorUserID,
|
|
58
|
+
pinnedTime: data.pinnedTime,
|
|
59
|
+
});
|
|
60
|
+
const { selectedConversationId, conversationData } = useConversationStore.getState();
|
|
61
|
+
const currentConversationId = selectedConversationId || (conversationData === null || conversationData === void 0 ? void 0 : conversationData.conversationID);
|
|
62
|
+
if (currentConversationId === data.conversationID) {
|
|
63
|
+
void fetchPinnedMessages(data.conversationID);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
52
66
|
const inCurrentConversation = (newServerMsg) => {
|
|
53
67
|
const selectedSourceId = useConversationStore.getState().selectedSourceId;
|
|
54
68
|
switch (newServerMsg.sessionType) {
|
|
@@ -203,6 +217,7 @@ export const useGlobalEvent = () => {
|
|
|
203
217
|
// message
|
|
204
218
|
DChatSDK.on(CbEvents.OnRecvNewMessages, newMessageHandler);
|
|
205
219
|
DChatSDK.on(CbEvents.OnNewRecvMessageRevoked, revokedMessageHandler);
|
|
220
|
+
DChatSDK.on(CbEvents.OnRecvMessagePinned, messagePinnedHandler);
|
|
206
221
|
// conversation
|
|
207
222
|
DChatSDK.on(CbEvents.OnConversationChanged, conversationChangeHandler);
|
|
208
223
|
DChatSDK.on(CbEvents.OnNewConversation, newConversationHandler);
|
|
@@ -226,6 +241,7 @@ export const useGlobalEvent = () => {
|
|
|
226
241
|
DChatSDK.off(CbEvents.OnSyncServerFailed, syncFailedHandler);
|
|
227
242
|
// message
|
|
228
243
|
DChatSDK.off(CbEvents.OnRecvNewMessages, newMessageHandler);
|
|
244
|
+
DChatSDK.off(CbEvents.OnRecvMessagePinned, messagePinnedHandler);
|
|
229
245
|
// conversation
|
|
230
246
|
DChatSDK.off(CbEvents.OnConversationChanged, conversationChangeHandler);
|
|
231
247
|
DChatSDK.off(CbEvents.OnNewConversation, newConversationHandler);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageItem, MessageType } from "@openim/wasm-client-sdk";
|
|
2
2
|
export declare const visibleTypeMessage: MessageType[];
|
|
3
|
-
export declare const useMessage: (conversationId?: string, searchClientMsgID?: string, enabled?: boolean) => {
|
|
3
|
+
export declare const useMessage: (conversationId?: string, searchClientMsgID?: string, enabled?: boolean, useAppHistory?: boolean) => {
|
|
4
4
|
loadState: {
|
|
5
5
|
initLoading: boolean;
|
|
6
6
|
hasMoreOld: boolean;
|
|
@@ -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,EACd,uBAAqB;;;;;qBAeA,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CA4RnC,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"}
|
|
@@ -25,7 +25,7 @@ export const visibleTypeMessage = [
|
|
|
25
25
|
MessageType.RevokeMessage,
|
|
26
26
|
MessageType.LogTextMessage,
|
|
27
27
|
];
|
|
28
|
-
export const useMessage = (conversationId, searchClientMsgID, enabled = true) => {
|
|
28
|
+
export const useMessage = (conversationId, searchClientMsgID, enabled = true, useAppHistory = false) => {
|
|
29
29
|
const { connectStatus, syncStatus } = useChatContext();
|
|
30
30
|
const userID = useAuthStore((state) => state.userID);
|
|
31
31
|
const canLoad = enabled &&
|
|
@@ -54,7 +54,9 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
|
|
|
54
54
|
viewType: ViewType.History,
|
|
55
55
|
};
|
|
56
56
|
try {
|
|
57
|
-
const { data } =
|
|
57
|
+
const { data } = useAppHistory
|
|
58
|
+
? await DChatSDK.getAdvancedHistoryMessageListApp(params)
|
|
59
|
+
: await DChatSDK.getAdvancedHistoryMessageList(params);
|
|
58
60
|
if (conversationIdRef.current !== reqConversationID)
|
|
59
61
|
return;
|
|
60
62
|
setTimeout(() => {
|
|
@@ -82,14 +84,17 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
|
|
|
82
84
|
var _a, _b;
|
|
83
85
|
const reqConversationID = conversationId;
|
|
84
86
|
try {
|
|
85
|
-
const
|
|
87
|
+
const reverseParams = {
|
|
86
88
|
count: PAGE_SIZE.large,
|
|
87
89
|
startClientMsgID: loadMore
|
|
88
90
|
? ((_b = (_a = latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList[0]) === null || _b === void 0 ? void 0 : _b.clientMsgID) || ""
|
|
89
91
|
: "",
|
|
90
92
|
conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
|
91
93
|
viewType: ViewType.Search,
|
|
92
|
-
}
|
|
94
|
+
};
|
|
95
|
+
const { data } = useAppHistory
|
|
96
|
+
? await DChatSDK.getAdvancedHistoryMessageListReverseApp(reverseParams)
|
|
97
|
+
: await DChatSDK.getAdvancedHistoryMessageListReverse(reverseParams);
|
|
93
98
|
if (conversationIdRef.current !== reqConversationID)
|
|
94
99
|
return;
|
|
95
100
|
setTimeout(() => {
|
|
@@ -118,18 +123,24 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
|
|
|
118
123
|
if (!searchClientMsgID || !conversationId)
|
|
119
124
|
return;
|
|
120
125
|
const reqConversationID = conversationId;
|
|
121
|
-
const
|
|
126
|
+
const searchPrevParams = {
|
|
122
127
|
count: PAGE_SIZE.small,
|
|
123
128
|
startClientMsgID: searchClientMsgID,
|
|
124
129
|
conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
|
125
130
|
viewType: ViewType.History,
|
|
126
|
-
}
|
|
127
|
-
const
|
|
131
|
+
};
|
|
132
|
+
const searchNextParams = {
|
|
128
133
|
count: PAGE_SIZE.small,
|
|
129
134
|
startClientMsgID: searchClientMsgID,
|
|
130
135
|
conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
|
131
136
|
viewType: ViewType.Search,
|
|
132
|
-
}
|
|
137
|
+
};
|
|
138
|
+
const { data: dataPrev } = useAppHistory
|
|
139
|
+
? await DChatSDK.getAdvancedHistoryMessageListApp(searchPrevParams)
|
|
140
|
+
: await DChatSDK.getAdvancedHistoryMessageList(searchPrevParams);
|
|
141
|
+
const { data: dataNext } = useAppHistory
|
|
142
|
+
? await DChatSDK.getAdvancedHistoryMessageListReverseApp(searchNextParams)
|
|
143
|
+
: await DChatSDK.getAdvancedHistoryMessageListReverse(searchNextParams);
|
|
133
144
|
const { data: dataCurrent } = await DChatSDK.findMessageList([
|
|
134
145
|
{
|
|
135
146
|
conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/store/conversation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAM3C,QAAA,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/store/conversation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAM3C,QAAA,MAAM,oBAAoB,gFAgOvB,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
|
|
@@ -17,13 +17,16 @@ const useConversationStore = create((set, get) => ({
|
|
|
17
17
|
});
|
|
18
18
|
},
|
|
19
19
|
selectedConversationId: "",
|
|
20
|
-
setSelectedConversationId: (threadId) =>
|
|
21
|
-
selectedConversationId
|
|
22
|
-
quotedMessage: null,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
setSelectedConversationId: (threadId) => {
|
|
21
|
+
const isSameConversation = get().selectedConversationId === threadId;
|
|
22
|
+
set(Object.assign({ selectedConversationId: threadId, quotedMessage: null }, (isSameConversation
|
|
23
|
+
? {}
|
|
24
|
+
: {
|
|
25
|
+
pinnedMessageList: [],
|
|
26
|
+
pinnedTotalCount: 0,
|
|
27
|
+
pinnedListIsEnd: false,
|
|
28
|
+
})));
|
|
29
|
+
},
|
|
27
30
|
selectedSourceId: "",
|
|
28
31
|
// conversation
|
|
29
32
|
conversationList: [],
|