@droppii-org/chat-sdk 0.1.54 → 0.1.56
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/BizThreadAvatar.d.ts +3 -3
- package/dist/components/biz-inbox/BizThreadAvatar.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadAvatar.js +5 -5
- package/dist/components/biz-inbox/BizThreadCard.d.ts +3 -3
- package/dist/components/biz-inbox/BizThreadCard.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadCard.js +7 -8
- package/dist/components/biz-inbox/BizThreadList.d.ts +3 -3
- package/dist/components/biz-inbox/BizThreadList.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadList.js +4 -8
- package/dist/components/biz-inbox/BizThreadTitle.d.ts +3 -3
- package/dist/components/biz-inbox/BizThreadTitle.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadTitle.js +5 -5
- package/dist/components/biz-thread-detail/BizMessageList.d.ts +5 -1
- package/dist/components/biz-thread-detail/BizMessageList.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizMessageList.js +7 -23
- package/dist/components/biz-thread-detail/BizThreadDetailHeader.d.ts +2 -2
- package/dist/components/biz-thread-detail/BizThreadDetailHeader.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizThreadDetailHeader.js +7 -5
- package/dist/components/biz-thread-detail/BizThreadDetailInput.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizThreadDetailInput.js +8 -13
- package/dist/components/biz-thread-detail/bot/BotButtonMessage.d.ts +8 -1
- package/dist/components/biz-thread-detail/bot/BotButtonMessage.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/bot/BotButtonMessage.js +5 -4
- package/dist/components/biz-thread-detail/bot/index.d.ts +1 -2
- package/dist/components/biz-thread-detail/bot/index.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/bot/index.js +0 -1
- package/dist/components/conversation-detail/ConversationDetailHeader.d.ts +8 -0
- package/dist/components/conversation-detail/ConversationDetailHeader.d.ts.map +1 -0
- package/dist/components/conversation-detail/ConversationDetailHeader.js +18 -0
- package/dist/components/conversation-detail/ConversationDetailInput.d.ts +8 -0
- package/dist/components/conversation-detail/ConversationDetailInput.d.ts.map +1 -0
- package/dist/components/conversation-detail/ConversationDetailInput.js +258 -0
- package/dist/components/conversation-detail/ConversationMessageList.d.ts +7 -0
- package/dist/components/conversation-detail/ConversationMessageList.d.ts.map +1 -0
- package/dist/components/conversation-detail/ConversationMessageList.js +35 -0
- package/dist/components/conversation-detail/ConversationMoreOptionItem.d.ts +8 -0
- package/dist/components/conversation-detail/ConversationMoreOptionItem.d.ts.map +1 -0
- package/dist/components/conversation-detail/ConversationMoreOptionItem.js +19 -0
- package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts +10 -0
- package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts.map +1 -0
- package/dist/components/conversation-detail/ConversationMoreOptionPanel.js +20 -0
- package/dist/components/conversation-detail/bot/BotButtonMessage.d.ts +10 -0
- package/dist/components/conversation-detail/bot/BotButtonMessage.d.ts.map +1 -0
- package/dist/components/conversation-detail/bot/BotButtonMessage.js +30 -0
- package/dist/components/conversation-detail/bot/BotStartButton.d.ts +8 -0
- package/dist/components/conversation-detail/bot/BotStartButton.d.ts.map +1 -0
- package/dist/components/conversation-detail/bot/BotStartButton.js +11 -0
- package/dist/components/conversation-detail/bot/BotSuggest.d.ts +7 -0
- package/dist/components/conversation-detail/bot/BotSuggest.d.ts.map +1 -0
- package/dist/components/conversation-detail/bot/BotSuggest.js +11 -0
- package/dist/components/conversation-detail/bot/index.d.ts +7 -0
- package/dist/components/conversation-detail/bot/index.d.ts.map +1 -0
- package/dist/components/conversation-detail/bot/index.js +3 -0
- package/dist/components/conversation-detail/index.d.ts +10 -0
- package/dist/components/conversation-detail/index.d.ts.map +1 -0
- package/dist/components/conversation-detail/index.js +5 -0
- package/dist/components/conversation-inbox/ConversationInboxHeader.d.ts +3 -0
- package/dist/components/conversation-inbox/ConversationInboxHeader.d.ts.map +1 -0
- package/dist/components/conversation-inbox/ConversationInboxHeader.js +8 -0
- package/dist/components/conversation-inbox/ConversationInboxItem.d.ts +8 -0
- package/dist/components/conversation-inbox/ConversationInboxItem.d.ts.map +1 -0
- package/dist/components/conversation-inbox/ConversationInboxItem.js +30 -0
- package/dist/components/conversation-inbox/ConversationInboxList.d.ts +12 -0
- package/dist/components/conversation-inbox/ConversationInboxList.d.ts.map +1 -0
- package/dist/components/conversation-inbox/ConversationInboxList.js +36 -0
- package/dist/components/conversation-inbox/ConversationInboxTitle.d.ts +9 -0
- package/dist/components/conversation-inbox/ConversationInboxTitle.d.ts.map +1 -0
- package/dist/components/conversation-inbox/ConversationInboxTitle.js +7 -0
- package/dist/components/conversation-inbox/ConversationPeerAvatar.d.ts +10 -0
- package/dist/components/conversation-inbox/ConversationPeerAvatar.d.ts.map +1 -0
- package/dist/components/conversation-inbox/ConversationPeerAvatar.js +10 -0
- package/dist/components/conversation-inbox/index.d.ts +10 -0
- package/dist/components/conversation-inbox/index.d.ts.map +1 -0
- package/dist/components/conversation-inbox/index.js +5 -0
- package/dist/components/message/footer/LinkInputPreview.js +1 -1
- package/dist/components/message/item/ImageMessage.js +1 -1
- package/dist/components/message/item/LinkCard.js +1 -1
- package/dist/components/message/item/LinkText.js +1 -1
- package/dist/components/message/item/VideoMessage.js +1 -1
- package/dist/components/message/item/index.d.ts +2 -1
- package/dist/components/message/item/index.d.ts.map +1 -1
- package/dist/components/message/item/index.js +2 -7
- package/dist/components/message/item/mediaSize.d.ts.map +1 -1
- package/dist/components/message/item/mediaSize.js +8 -8
- package/dist/constants/botFlow.d.ts +0 -5
- package/dist/constants/botFlow.d.ts.map +1 -1
- package/dist/constants/botFlow.js +0 -11
- package/dist/constants/moreOption.d.ts +9 -0
- package/dist/constants/moreOption.d.ts.map +1 -0
- package/dist/constants/moreOption.js +37 -0
- package/dist/hooks/biz/useBotFlow.d.ts +3 -2
- package/dist/hooks/biz/useBotFlow.d.ts.map +1 -1
- package/dist/hooks/biz/useBotFlow.js +61 -2
- package/dist/hooks/biz/useRunBotFlow.d.ts +3 -2
- package/dist/hooks/biz/useRunBotFlow.d.ts.map +1 -1
- package/dist/hooks/conversation/useActiveConversation.d.ts +3 -0
- package/dist/hooks/conversation/useActiveConversation.d.ts.map +1 -0
- package/dist/hooks/conversation/useActiveConversation.js +31 -0
- package/dist/hooks/conversation/useBotConversationDetail.d.ts +3 -0
- package/dist/hooks/conversation/useBotConversationDetail.d.ts.map +1 -0
- package/dist/hooks/conversation/useBotConversationDetail.js +18 -0
- package/dist/hooks/conversation/useBotFlow.d.ts +18 -0
- package/dist/hooks/conversation/useBotFlow.d.ts.map +1 -0
- package/dist/hooks/conversation/useBotFlow.js +150 -0
- package/dist/hooks/conversation/useConversationList.d.ts +15 -0
- package/dist/hooks/conversation/useConversationList.d.ts.map +1 -0
- package/dist/hooks/conversation/useConversationList.js +70 -0
- package/dist/hooks/conversation/useCreateConversation.d.ts +8 -0
- package/dist/hooks/conversation/useCreateConversation.d.ts.map +1 -0
- package/dist/hooks/conversation/useCreateConversation.js +15 -0
- package/dist/hooks/conversation/useResetBotFlow.d.ts +3 -0
- package/dist/hooks/conversation/useResetBotFlow.d.ts.map +1 -0
- package/dist/hooks/conversation/useResetBotFlow.js +14 -0
- package/dist/hooks/conversation/useRunBotFlow.d.ts +7 -0
- package/dist/hooks/conversation/useRunBotFlow.d.ts.map +1 -0
- package/dist/hooks/conversation/useRunBotFlow.js +14 -0
- package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
- package/dist/hooks/global/useGlobalEvent.js +15 -7
- package/dist/hooks/message/useMessage.d.ts.map +1 -1
- package/dist/hooks/message/useMessage.js +0 -2
- package/dist/hooks/message/useSendMessage.d.ts +6 -4
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +6 -2
- package/dist/hooks/user/useAuth.js +2 -2
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/locales/i18n.js +3 -3
- package/dist/locales/i18n.ts +3 -3
- package/dist/locales/vi/biz-inbox.json +39 -39
- package/dist/locales/vi/conversation-inbox.json +39 -0
- package/dist/screens/biz-message/index.d.ts +3 -4
- package/dist/screens/biz-message/index.d.ts.map +1 -1
- package/dist/screens/biz-message/index.js +5 -9
- package/dist/screens/biz-thread-detail/index.d.ts.map +1 -1
- package/dist/screens/biz-thread-detail/index.js +10 -14
- package/dist/screens/conversation-detail/index.d.ts +9 -0
- package/dist/screens/conversation-detail/index.d.ts.map +1 -0
- package/dist/screens/conversation-detail/index.js +53 -0
- package/dist/screens/conversation-inbox/index.d.ts +8 -0
- package/dist/screens/conversation-inbox/index.d.ts.map +1 -0
- package/dist/screens/conversation-inbox/index.js +30 -0
- package/dist/services/query.d.ts +0 -1
- package/dist/services/query.d.ts.map +1 -1
- package/dist/services/query.js +0 -1
- package/dist/services/routes.d.ts +0 -1
- package/dist/services/routes.d.ts.map +1 -1
- package/dist/services/routes.js +0 -1
- package/dist/store/conversation.d.ts.map +1 -1
- package/dist/store/conversation.js +14 -5
- package/dist/store/messageDraft.d.ts +9 -0
- package/dist/store/messageDraft.d.ts.map +1 -0
- package/dist/store/messageDraft.js +35 -0
- package/dist/store/type.d.ts +6 -1
- package/dist/store/type.d.ts.map +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/biz.d.ts +1 -5
- package/dist/types/biz.d.ts.map +1 -1
- package/dist/types/chat.d.ts +6 -0
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/conversation.d.ts +116 -0
- package/dist/types/conversation.d.ts.map +1 -0
- package/dist/types/conversation.js +33 -0
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js +5 -3
- package/dist/utils/conversation.d.ts +12 -0
- package/dist/utils/conversation.d.ts.map +1 -0
- package/dist/utils/conversation.js +53 -0
- package/dist/utils/events.d.ts +1 -1
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/utils/fileValidation.d.ts +2 -1
- package/dist/utils/fileValidation.d.ts.map +1 -1
- package/dist/utils/fileValidation.js +10 -1
- package/dist/utils/imCommon.d.ts +1 -0
- package/dist/utils/imCommon.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { BotBlockType, BotFlowNodeType, } from "../../types/conversation";
|
|
5
|
+
import { BOT_DEFAULT_BUTTON_ID } from "../../constants/botFlow";
|
|
6
|
+
import { useSendMessage } from "../../hooks/message/useSendMessage";
|
|
7
|
+
import useAuthStore from "../../store/auth";
|
|
8
|
+
import emitter from "../../utils/events";
|
|
9
|
+
import { useBotConversationDetail } from "./useBotConversationDetail";
|
|
10
|
+
import { useRunBotFlow } from "./useRunBotFlow";
|
|
11
|
+
import { useResetBotFlow } from "./useResetBotFlow";
|
|
12
|
+
const INITIAL_BOT_FLOW_STATE = {
|
|
13
|
+
conversationId: "",
|
|
14
|
+
flowCurrentStep: null,
|
|
15
|
+
flowIsEnd: false,
|
|
16
|
+
};
|
|
17
|
+
const parseMessageFlowGroupId = (ex) => {
|
|
18
|
+
var _a;
|
|
19
|
+
try {
|
|
20
|
+
return (_a = JSON.parse(ex || "{}").flow) === null || _a === void 0 ? void 0 : _a.groupId;
|
|
21
|
+
}
|
|
22
|
+
catch (_b) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const [botFlowState, setBotFlowState] = useState(INITIAL_BOT_FLOW_STATE);
|
|
29
|
+
const { conversationId: storedConversationId, flowCurrentStep } = botFlowState;
|
|
30
|
+
const isActiveConversation = storedConversationId === conversationId;
|
|
31
|
+
const flowIsEnd = isActiveConversation && botFlowState.flowIsEnd;
|
|
32
|
+
const [pendingGroupId, setPendingGroupId] = useState(null);
|
|
33
|
+
const latestBotFlowGroupIdRef = useRef(null);
|
|
34
|
+
const authUserID = useAuthStore((state) => state.userID);
|
|
35
|
+
const { t } = useTranslation("conversation-inbox");
|
|
36
|
+
const detailQuery = useBotConversationDetail(conversationId, isBotThread);
|
|
37
|
+
const runMutation = useRunBotFlow();
|
|
38
|
+
const resetMutation = useResetBotFlow();
|
|
39
|
+
const { sendMergeMessage } = useSendMessage({
|
|
40
|
+
scrollEvent: "CONVERSATION_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM",
|
|
41
|
+
});
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!isBotThread) {
|
|
44
|
+
setBotFlowState(INITIAL_BOT_FLOW_STATE);
|
|
45
|
+
setPendingGroupId(null);
|
|
46
|
+
latestBotFlowGroupIdRef.current = null;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (detailQuery.data) {
|
|
50
|
+
setBotFlowState({
|
|
51
|
+
conversationId,
|
|
52
|
+
flowCurrentStep: detailQuery.data.flowCurrentStep,
|
|
53
|
+
flowIsEnd: detailQuery.data.flowIsEnd,
|
|
54
|
+
});
|
|
55
|
+
setPendingGroupId(null);
|
|
56
|
+
latestBotFlowGroupIdRef.current = null;
|
|
57
|
+
}
|
|
58
|
+
}, [isBotThread, conversationId, detailQuery.data]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const handleNewMessage = (message) => {
|
|
61
|
+
if (message.sendID === authUserID)
|
|
62
|
+
return;
|
|
63
|
+
const groupId = parseMessageFlowGroupId(message.ex);
|
|
64
|
+
if (!groupId)
|
|
65
|
+
return;
|
|
66
|
+
latestBotFlowGroupIdRef.current = groupId;
|
|
67
|
+
setPendingGroupId((currentGroupId) => currentGroupId === groupId ? null : currentGroupId);
|
|
68
|
+
};
|
|
69
|
+
emitter.on("PUSH_NEW_MSG", handleNewMessage);
|
|
70
|
+
return () => {
|
|
71
|
+
emitter.off("PUSH_NEW_MSG", handleNewMessage);
|
|
72
|
+
};
|
|
73
|
+
}, [authUserID]);
|
|
74
|
+
const activeStep = storedConversationId === conversationId ? flowCurrentStep : null;
|
|
75
|
+
const currentButtonsBlock = (_a = activeStep === null || activeStep === void 0 ? void 0 : activeStep.data.children.find((child) => child.type === BotBlockType.InputButtons)) !== null && _a !== void 0 ? _a : null;
|
|
76
|
+
const isProcessing = runMutation.isPending || resetMutation.isPending;
|
|
77
|
+
const shouldShowButtons = !!currentButtonsBlock && !isProcessing && !pendingGroupId;
|
|
78
|
+
const status = (activeStep === null || activeStep === void 0 ? void 0 : activeStep.type) === BotFlowNodeType.Start ? "not_started" : "running";
|
|
79
|
+
const runStep = async (step, actionId = null) => {
|
|
80
|
+
var _a;
|
|
81
|
+
latestBotFlowGroupIdRef.current = null;
|
|
82
|
+
const result = await runMutation.mutateAsync({
|
|
83
|
+
conversationId,
|
|
84
|
+
groupId: step.id,
|
|
85
|
+
childId: null,
|
|
86
|
+
actionId,
|
|
87
|
+
});
|
|
88
|
+
setBotFlowState({
|
|
89
|
+
conversationId,
|
|
90
|
+
flowCurrentStep: result.flowNextStep,
|
|
91
|
+
flowIsEnd: result.isEnd,
|
|
92
|
+
});
|
|
93
|
+
const nextGroupId = (_a = result.flowNextStep) === null || _a === void 0 ? void 0 : _a.id;
|
|
94
|
+
setPendingGroupId(result.havingBotMessage &&
|
|
95
|
+
nextGroupId &&
|
|
96
|
+
latestBotFlowGroupIdRef.current !== nextGroupId
|
|
97
|
+
? nextGroupId
|
|
98
|
+
: null);
|
|
99
|
+
};
|
|
100
|
+
const start = async () => {
|
|
101
|
+
if (!activeStep)
|
|
102
|
+
return;
|
|
103
|
+
await runStep(activeStep);
|
|
104
|
+
};
|
|
105
|
+
const selectButton = async (actionId) => {
|
|
106
|
+
if (!activeStep)
|
|
107
|
+
return;
|
|
108
|
+
const flow = {
|
|
109
|
+
groupId: activeStep.id,
|
|
110
|
+
childId: null,
|
|
111
|
+
actionId,
|
|
112
|
+
};
|
|
113
|
+
const selectedButton = currentButtonsBlock === null || currentButtonsBlock === void 0 ? void 0 : currentButtonsBlock.data.buttons.find((button) => button.id === actionId);
|
|
114
|
+
if (selectedButton) {
|
|
115
|
+
await sendMergeMessage({
|
|
116
|
+
plainText: selectedButton.label,
|
|
117
|
+
richText: "",
|
|
118
|
+
isInternal: false,
|
|
119
|
+
flow,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
await runStep(activeStep, actionId);
|
|
123
|
+
};
|
|
124
|
+
const restart = async () => {
|
|
125
|
+
var _a;
|
|
126
|
+
const flow = {
|
|
127
|
+
groupId: (_a = activeStep === null || activeStep === void 0 ? void 0 : activeStep.id) !== null && _a !== void 0 ? _a : "",
|
|
128
|
+
childId: null,
|
|
129
|
+
actionId: BOT_DEFAULT_BUTTON_ID,
|
|
130
|
+
};
|
|
131
|
+
await sendMergeMessage({
|
|
132
|
+
plainText: t("thread_detail.bot.restart"),
|
|
133
|
+
richText: "",
|
|
134
|
+
isInternal: false,
|
|
135
|
+
flow,
|
|
136
|
+
});
|
|
137
|
+
const resetDetail = await resetMutation.mutateAsync(conversationId);
|
|
138
|
+
await runStep(resetDetail.flowCurrentStep);
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
status,
|
|
142
|
+
flowIsEnd,
|
|
143
|
+
isProcessing,
|
|
144
|
+
shouldShowButtons,
|
|
145
|
+
currentButtonsBlock,
|
|
146
|
+
start,
|
|
147
|
+
selectButton,
|
|
148
|
+
restart,
|
|
149
|
+
};
|
|
150
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatCategory, type ConversationListItem } from "../../types/conversation";
|
|
2
|
+
interface UseConversationListParams {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
chatCategory?: ChatCategory;
|
|
5
|
+
}
|
|
6
|
+
interface UseConversationListResult {
|
|
7
|
+
items: ConversationListItem[];
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
isFetchingNextPage: boolean;
|
|
10
|
+
hasNextPage: boolean;
|
|
11
|
+
fetchNextPage: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const useConversationList: (params: UseConversationListParams) => UseConversationListResult;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=useConversationList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConversationList.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversationList.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAI/E,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,UAAU,yBAAyB;IACjC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AASD,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB,KAChC,yBAuFF,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { CbEvents, } from "@openim/wasm-client-sdk";
|
|
4
|
+
import { DChatSDK } from "../../constants/sdk";
|
|
5
|
+
import { useChatContext } from "../../context/ChatContext";
|
|
6
|
+
import { ConnectStatus, DChatApplicationType } from "../../types/chat";
|
|
7
|
+
import useAuthStore from "../../store/auth";
|
|
8
|
+
import useConversationStore from "../../store/conversation";
|
|
9
|
+
const toConversationListItem = (conversation) => (Object.assign(Object.assign({}, conversation), { peerType: conversation.peerType }));
|
|
10
|
+
export const useConversationList = (params) => {
|
|
11
|
+
const { enabled, chatCategory } = params;
|
|
12
|
+
const { connectStatus } = useChatContext();
|
|
13
|
+
const applicationType = useAuthStore((state) => state.applicationType);
|
|
14
|
+
const conversationList = useConversationStore((state) => state.conversationList);
|
|
15
|
+
const getConversationListByReq = useConversationStore((state) => state.getConversationListByReq);
|
|
16
|
+
const updateConversationList = useConversationStore((state) => state.updateConversationList);
|
|
17
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
18
|
+
const [isFetchingNextPage, setIsFetchingNextPage] = useState(false);
|
|
19
|
+
const [hasNextPage, setHasNextPage] = useState(false);
|
|
20
|
+
const isApplicationTypeValid = Object.values(DChatApplicationType).includes(applicationType);
|
|
21
|
+
const queryEnabled = enabled &&
|
|
22
|
+
isApplicationTypeValid &&
|
|
23
|
+
connectStatus === ConnectStatus.Connected;
|
|
24
|
+
const appParams = useMemo(() => ({ applicationType, chatCategory }), [applicationType, chatCategory]);
|
|
25
|
+
const loadInitial = useCallback(async () => {
|
|
26
|
+
setIsLoading(true);
|
|
27
|
+
try {
|
|
28
|
+
const hasMore = await getConversationListByReq(false, appParams);
|
|
29
|
+
setHasNextPage(hasMore);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
setIsLoading(false);
|
|
33
|
+
}
|
|
34
|
+
}, [getConversationListByReq, appParams]);
|
|
35
|
+
const fetchNextPage = useCallback(() => {
|
|
36
|
+
if (!hasNextPage || isFetchingNextPage)
|
|
37
|
+
return;
|
|
38
|
+
setIsFetchingNextPage(true);
|
|
39
|
+
void getConversationListByReq(true, appParams)
|
|
40
|
+
.then((hasMore) => setHasNextPage(hasMore))
|
|
41
|
+
.finally(() => setIsFetchingNextPage(false));
|
|
42
|
+
}, [hasNextPage, isFetchingNextPage, getConversationListByReq, appParams]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!queryEnabled)
|
|
45
|
+
return;
|
|
46
|
+
void loadInitial();
|
|
47
|
+
const onSyncFinish = () => {
|
|
48
|
+
void loadInitial();
|
|
49
|
+
};
|
|
50
|
+
const conversationChangeHandler = ({ data, }) => {
|
|
51
|
+
updateConversationList(data, "push");
|
|
52
|
+
};
|
|
53
|
+
DChatSDK.on(CbEvents.OnSyncServerFinish, onSyncFinish);
|
|
54
|
+
DChatSDK.on(CbEvents.OnConversationChanged, conversationChangeHandler);
|
|
55
|
+
DChatSDK.on(CbEvents.OnNewConversation, conversationChangeHandler);
|
|
56
|
+
return () => {
|
|
57
|
+
DChatSDK.off(CbEvents.OnSyncServerFinish, onSyncFinish);
|
|
58
|
+
DChatSDK.off(CbEvents.OnConversationChanged, conversationChangeHandler);
|
|
59
|
+
DChatSDK.off(CbEvents.OnNewConversation, conversationChangeHandler);
|
|
60
|
+
};
|
|
61
|
+
}, [queryEnabled, loadInitial, updateConversationList]);
|
|
62
|
+
const items = useMemo(() => conversationList.map(toConversationListItem), [conversationList]);
|
|
63
|
+
return {
|
|
64
|
+
items,
|
|
65
|
+
isLoading,
|
|
66
|
+
isFetchingNextPage,
|
|
67
|
+
hasNextPage,
|
|
68
|
+
fetchNextPage,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChatCategory, ChatType, CreateConversationData } from "../../types/conversation";
|
|
2
|
+
export interface CreateConversationInput {
|
|
3
|
+
peerUserId: string;
|
|
4
|
+
chatCategory: ChatCategory;
|
|
5
|
+
chatType: ChatType;
|
|
6
|
+
}
|
|
7
|
+
export declare const useCreateConversation: () => import("@tanstack/react-query").UseMutationResult<CreateConversationData, Error, CreateConversationInput, unknown>;
|
|
8
|
+
//# sourceMappingURL=useCreateConversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useCreateConversation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,eAAO,MAAM,qBAAqB,0HAejC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import useAuthStore from "../../store/auth";
|
|
4
|
+
import { apiInstance } from "../../services/api";
|
|
5
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
6
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
7
|
+
export const useCreateConversation = () => {
|
|
8
|
+
return useMutation({
|
|
9
|
+
mutationKey: [QUERY_KEYS.CREATE_BIZ_CONVERSATION],
|
|
10
|
+
mutationFn: async (input) => {
|
|
11
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.createBizConversation, Object.assign(Object.assign({}, input), { applicationType: useAuthStore.getState().applicationType }));
|
|
12
|
+
return res.data.data;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResetBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useResetBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,eAAO,MAAM,eAAe,wGAY3B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
6
|
+
export const useResetBotFlow = () => {
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutationKey: [QUERY_KEYS.RESET_BOT_FLOW],
|
|
9
|
+
mutationFn: async (conversationId) => {
|
|
10
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.resetBotFlow(conversationId));
|
|
11
|
+
return res.data.data;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BotFlowMeta } from "../../types/chat";
|
|
2
|
+
import type { RunBotFlowResponse } from "../../types/conversation";
|
|
3
|
+
export interface RunBotFlowParams extends BotFlowMeta {
|
|
4
|
+
conversationId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const useRunBotFlow: () => import("@tanstack/react-query").UseMutationResult<RunBotFlowResponse, Error, RunBotFlowParams, unknown>;
|
|
7
|
+
//# sourceMappingURL=useRunBotFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useRunBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,aAAa,+GAgBzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
6
|
+
export const useRunBotFlow = () => {
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutationKey: [QUERY_KEYS.RUN_BOT_FLOW],
|
|
9
|
+
mutationFn: async ({ conversationId, groupId, childId, actionId, }) => {
|
|
10
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.runBotFlow(conversationId), { groupId, childId, actionId });
|
|
11
|
+
return res.data.data;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,cAAc,YA+T1B,CAAC"}
|
|
@@ -65,13 +65,17 @@ export const useGlobalEvent = () => {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
const handleNewMessage = (newServerMsg) => {
|
|
68
|
+
var _a, _b;
|
|
68
69
|
let customData = null;
|
|
69
70
|
if (newServerMsg.contentType === MessageType.CustomMessage) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
const rawCustomData = (_b = (_a = newServerMsg.customElem) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.trim();
|
|
72
|
+
if (rawCustomData === null || rawCustomData === void 0 ? void 0 : rawCustomData.startsWith("{")) {
|
|
73
|
+
try {
|
|
74
|
+
customData = JSON.parse(rawCustomData);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
console.error("Failed to parse custom message data", e);
|
|
78
|
+
}
|
|
75
79
|
}
|
|
76
80
|
if (customData &&
|
|
77
81
|
CustomType.CallingInvite <= customData.customType &&
|
|
@@ -105,8 +109,12 @@ export const useGlobalEvent = () => {
|
|
|
105
109
|
},
|
|
106
110
|
});
|
|
107
111
|
};
|
|
112
|
+
const loadConversationList = () => {
|
|
113
|
+
const { isCrm, applicationType } = useAuthStore.getState();
|
|
114
|
+
getConversationListByReq(false, isCrm ? undefined : { applicationType });
|
|
115
|
+
};
|
|
108
116
|
const initStore = () => {
|
|
109
|
-
|
|
117
|
+
loadConversationList();
|
|
110
118
|
};
|
|
111
119
|
const tryLogin = async () => {
|
|
112
120
|
const { userID, chatToken, platformID, wsAddress } = useAuthStore.getState();
|
|
@@ -154,7 +162,7 @@ export const useGlobalEvent = () => {
|
|
|
154
162
|
const syncFinishHandler = () => {
|
|
155
163
|
updateSyncStatus(SyncStatus.Success);
|
|
156
164
|
getSelfUserInfo();
|
|
157
|
-
|
|
165
|
+
loadConversationList();
|
|
158
166
|
void refreshCurrentGroupState();
|
|
159
167
|
};
|
|
160
168
|
const syncFailedHandler = () => {
|
|
@@ -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;
|
|
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"}
|
|
@@ -8,7 +8,6 @@ import isEmpty from "lodash/isEmpty";
|
|
|
8
8
|
import { useChatContext } from "../../context/ChatContext";
|
|
9
9
|
import useAuthStore from "../../store/auth";
|
|
10
10
|
import { ConnectStatus, SyncStatus } from "../../types/chat";
|
|
11
|
-
import { BOT_BUTTONS_MESSAGE_TYPE } from "../../constants/botFlow";
|
|
12
11
|
export const visibleTypeMessage = [
|
|
13
12
|
MessageType.TextMessage,
|
|
14
13
|
MessageType.PictureMessage,
|
|
@@ -25,7 +24,6 @@ export const visibleTypeMessage = [
|
|
|
25
24
|
MessageType.UrlTextMessage,
|
|
26
25
|
MessageType.RevokeMessage,
|
|
27
26
|
MessageType.LogTextMessage,
|
|
28
|
-
BOT_BUTTONS_MESSAGE_TYPE,
|
|
29
27
|
];
|
|
30
28
|
export const useMessage = (conversationId, searchClientMsgID, enabled = true) => {
|
|
31
29
|
const { connectStatus, syncStatus } = useChatContext();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MergerMsgParams, MessageItem } from "@openim/wasm-client-sdk";
|
|
2
|
-
import { ExtendMessageInfo, FileMsgParamsByFile, ImageMsgParamsByFile, UrlMetadataInfo, VideoMsgParamsByFile } from "../../types/chat";
|
|
2
|
+
import { BotFlowMeta, ExtendMessageInfo, FileMsgParamsByFile, ImageMsgParamsByFile, UrlMetadataInfo, VideoMsgParamsByFile } from "../../types/chat";
|
|
3
3
|
import { UploadFile } from "antd";
|
|
4
4
|
import { ISessionResponse } from "../../types/dto";
|
|
5
5
|
export declare const isMediaResendable: (message: {
|
|
@@ -13,7 +13,7 @@ export declare const createVideoMessageByFile: (file: VideoMsgParamsByFile) => P
|
|
|
13
13
|
export declare const createFileMessageByFile: (file: FileMsgParamsByFile) => Promise<MessageItem | null>;
|
|
14
14
|
export declare const createUrlTextMessage: (text: string, urls: string[]) => Promise<MessageItem | null>;
|
|
15
15
|
export declare const createQuoteMessage: (text: string, quotedMessage: MessageItem) => Promise<MessageItem | null>;
|
|
16
|
-
export type SendMessageScrollEvent = "CHAT_LIST_SCROLL_TO_BOTTOM" | "
|
|
16
|
+
export type SendMessageScrollEvent = "CHAT_LIST_SCROLL_TO_BOTTOM" | "CONVERSATION_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM";
|
|
17
17
|
export interface OfflinePushMeta {
|
|
18
18
|
title: string;
|
|
19
19
|
icon: string;
|
|
@@ -26,19 +26,21 @@ export interface UseSendMessageOptions {
|
|
|
26
26
|
}) => OfflinePushMeta;
|
|
27
27
|
}
|
|
28
28
|
export declare const useSendMessage: (options?: UseSendMessageOptions) => {
|
|
29
|
-
sendMergeMessage: ({ richText, plainText, files, currentSession, isInternal, urlMetadata, }: {
|
|
29
|
+
sendMergeMessage: ({ richText, plainText, files, currentSession, isInternal, urlMetadata, flow, }: {
|
|
30
30
|
richText: string;
|
|
31
31
|
plainText: string;
|
|
32
32
|
files?: UploadFile[];
|
|
33
33
|
currentSession?: ISessionResponse;
|
|
34
34
|
isInternal: boolean;
|
|
35
35
|
urlMetadata?: UrlMetadataInfo;
|
|
36
|
+
flow?: BotFlowMeta;
|
|
36
37
|
}) => Promise<boolean>;
|
|
37
38
|
resendMessage: (failedMessage: MessageItem) => Promise<void>;
|
|
38
39
|
};
|
|
39
|
-
export declare const generateExtendMessageInfo: ({ richText, urlMetadata, currentSession, }: {
|
|
40
|
+
export declare const generateExtendMessageInfo: ({ richText, urlMetadata, currentSession, flow, }: {
|
|
40
41
|
richText?: string;
|
|
41
42
|
urlMetadata?: UrlMetadataInfo;
|
|
42
43
|
currentSession?: ISessionResponse;
|
|
44
|
+
flow?: BotFlowMeta;
|
|
43
45
|
}) => ExtendMessageInfo;
|
|
44
46
|
//# sourceMappingURL=useSendMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,e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,yBAAyB,GAAI,kDAKvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,sBA8BA,CAAC"}
|
|
@@ -272,7 +272,7 @@ export const useSendMessage = (options) => {
|
|
|
272
272
|
removeOneMessage(failedMessage.clientMsgID);
|
|
273
273
|
await sendMessage(Object.assign(Object.assign({}, newPayload), { ex: failedMessage.ex }));
|
|
274
274
|
}, [sendMessage]);
|
|
275
|
-
const sendMergeMessage = useCallback(async ({ richText, plainText, files = [], currentSession, isInternal, urlMetadata, }) => {
|
|
275
|
+
const sendMergeMessage = useCallback(async ({ richText, plainText, files = [], currentSession, isInternal, urlMetadata, flow, }) => {
|
|
276
276
|
if (!conversationData || (!recvID && !groupID))
|
|
277
277
|
return false;
|
|
278
278
|
const messageList = [];
|
|
@@ -422,6 +422,7 @@ export const useSendMessage = (options) => {
|
|
|
422
422
|
? urlMetadata
|
|
423
423
|
: undefined,
|
|
424
424
|
currentSession,
|
|
425
|
+
flow: isTextLikeMessage ? flow : undefined,
|
|
425
426
|
});
|
|
426
427
|
const mMessage = Object.assign(Object.assign({}, message), { ex: JSON.stringify(extendMessageInfo) || "{}", isInternal });
|
|
427
428
|
await sendMessage(mMessage, currentSession);
|
|
@@ -440,11 +441,14 @@ export const useSendMessage = (options) => {
|
|
|
440
441
|
resendMessage,
|
|
441
442
|
};
|
|
442
443
|
};
|
|
443
|
-
export const generateExtendMessageInfo = ({ richText, urlMetadata, currentSession, }) => {
|
|
444
|
+
export const generateExtendMessageInfo = ({ richText, urlMetadata, currentSession, flow, }) => {
|
|
444
445
|
const extendMessageInfo = {
|
|
445
446
|
sessionId: (currentSession === null || currentSession === void 0 ? void 0 : currentSession.id) || "",
|
|
446
447
|
applicationType: useAuthStore.getState().applicationType,
|
|
447
448
|
};
|
|
449
|
+
if (flow) {
|
|
450
|
+
extendMessageInfo.flow = flow;
|
|
451
|
+
}
|
|
448
452
|
const trimmedRichText = richText === null || richText === void 0 ? void 0 : richText.trim();
|
|
449
453
|
if (trimmedRichText) {
|
|
450
454
|
extendMessageInfo.messageInfo = {
|
|
@@ -2,11 +2,11 @@ import { Platform } from "@openim/wasm-client-sdk";
|
|
|
2
2
|
import { DChatSDK } from "../../constants/sdk";
|
|
3
3
|
import useAuthStore from "../../store/auth";
|
|
4
4
|
import useConversationStore from "../../store/conversation";
|
|
5
|
-
import
|
|
5
|
+
import useMessageDraftStore from "../../store/messageDraft";
|
|
6
6
|
export const useDChatAuth = () => {
|
|
7
7
|
const initAuthStore = useAuthStore((state) => state.initAuthStore);
|
|
8
8
|
const resetConversationStore = useConversationStore((state) => state.resetConversationStore);
|
|
9
|
-
const clearAllDrafts =
|
|
9
|
+
const clearAllDrafts = useMessageDraftStore((state) => state.clearAllDrafts);
|
|
10
10
|
const logout = async () => {
|
|
11
11
|
const res = await DChatSDK.logout();
|
|
12
12
|
const applicationType = useAuthStore.getState().applicationType;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,20 +13,21 @@ export * from "antd/es/table";
|
|
|
13
13
|
export { ChatProvider, useChatContext } from "./context/ChatContext";
|
|
14
14
|
export { DChatDeskMessage, DChatBubble, Icon };
|
|
15
15
|
export { default as RichTextEditor } from "./components/rich-text-editor/RichTextEditor";
|
|
16
|
-
export { default as
|
|
17
|
-
export type {
|
|
18
|
-
export { default as
|
|
19
|
-
export type {
|
|
20
|
-
export {
|
|
21
|
-
export type {
|
|
22
|
-
export {
|
|
23
|
-
export type {
|
|
16
|
+
export { default as DChatConversationInbox } from "./screens/conversation-inbox";
|
|
17
|
+
export type { DChatConversationInboxProps } from "./screens/conversation-inbox";
|
|
18
|
+
export { default as DChatConversationDetail } from "./screens/conversation-detail";
|
|
19
|
+
export type { DChatConversationDetailProps } from "./screens/conversation-detail";
|
|
20
|
+
export { ConversationDetailHeader, ConversationDetailInput, } from "./components/conversation-detail";
|
|
21
|
+
export type { ConversationDetailHeaderProps, ConversationDetailInputProps, } from "./components/conversation-detail";
|
|
22
|
+
export { ChatCategory, ChatType, PeerType, } from "./types/conversation";
|
|
23
|
+
export type { ConversationListItem, CreateConversationData, ConversationMember, } from "./types/conversation";
|
|
24
24
|
export { useDChatAuth } from "./hooks/user/useAuth";
|
|
25
25
|
export { useUpdateFcmToken } from "./hooks/user/useUpdateFcmToken";
|
|
26
|
-
export {
|
|
27
|
-
export
|
|
26
|
+
export { useConversationList } from "./hooks/conversation/useConversationList";
|
|
27
|
+
export { useCreateConversation } from "./hooks/conversation/useCreateConversation";
|
|
28
|
+
export type { CreateConversationInput } from "./hooks/conversation/useCreateConversation";
|
|
28
29
|
export { useUserStore, DChatApplicationType, useAuthStore };
|
|
29
|
-
export { default as
|
|
30
|
+
export { default as useConversationStore } from "./store/conversation";
|
|
30
31
|
export { Platform as DChatPlatform, LogLevel as DChatLogLevel, SessionType as DChatSessionType, };
|
|
31
32
|
export type { DChatInitAndLoginConfig };
|
|
32
33
|
export { getDChatSDK } from "./constants/sdk";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AACtD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,Q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,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACnF,YAAY,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAElF,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,YAAY,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAG1F,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIvE,OAAO,EACL,QAAQ,IAAI,aAAa,EACzB,QAAQ,IAAI,aAAa,EACzB,WAAW,IAAI,gBAAgB,GAChC,CAAC;AAEF,YAAY,EAAE,uBAAuB,EAAE,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,17 +15,18 @@ export { ChatProvider, useChatContext } from "./context/ChatContext";
|
|
|
15
15
|
//Components
|
|
16
16
|
export { DChatDeskMessage, DChatBubble, Icon };
|
|
17
17
|
export { default as RichTextEditor } from "./components/rich-text-editor/RichTextEditor";
|
|
18
|
-
export { default as
|
|
19
|
-
export { default as
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
18
|
+
export { default as DChatConversationInbox } from "./screens/conversation-inbox";
|
|
19
|
+
export { default as DChatConversationDetail } from "./screens/conversation-detail";
|
|
20
|
+
export { ConversationDetailHeader, ConversationDetailInput, } from "./components/conversation-detail";
|
|
21
|
+
export { ChatCategory, ChatType, PeerType, } from "./types/conversation";
|
|
22
22
|
//Hooks
|
|
23
23
|
export { useDChatAuth } from "./hooks/user/useAuth";
|
|
24
24
|
export { useUpdateFcmToken } from "./hooks/user/useUpdateFcmToken";
|
|
25
|
-
export {
|
|
25
|
+
export { useConversationList } from "./hooks/conversation/useConversationList";
|
|
26
|
+
export { useCreateConversation } from "./hooks/conversation/useCreateConversation";
|
|
26
27
|
//Store
|
|
27
28
|
export { useUserStore, DChatApplicationType, useAuthStore };
|
|
28
|
-
export { default as
|
|
29
|
+
export { default as useConversationStore } from "./store/conversation";
|
|
29
30
|
// export * from "./types/sdk";
|
|
30
31
|
export { Platform as DChatPlatform, LogLevel as DChatLogLevel, SessionType as DChatSessionType, };
|
|
31
32
|
export { getDChatSDK } from "./constants/sdk";
|
package/dist/locales/i18n.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import i18n from "i18next";
|
|
2
2
|
import { initReactI18next } from "react-i18next";
|
|
3
3
|
import vi from "./vi/common.json";
|
|
4
|
-
import
|
|
4
|
+
import viConversationInbox from "./vi/conversation-inbox.json";
|
|
5
5
|
if (!i18n.isInitialized) {
|
|
6
6
|
i18n.use(initReactI18next).init({
|
|
7
7
|
resources: {
|
|
8
|
-
vi: { common: vi, "
|
|
8
|
+
vi: { common: vi, "conversation-inbox": viConversationInbox },
|
|
9
9
|
},
|
|
10
10
|
lng: "vi",
|
|
11
11
|
fallbackLng: "vi",
|
|
12
12
|
interpolation: { escapeValue: false },
|
|
13
|
-
ns: ["common", "
|
|
13
|
+
ns: ["common", "conversation-inbox"],
|
|
14
14
|
defaultNS: "common",
|
|
15
15
|
});
|
|
16
16
|
}
|
package/dist/locales/i18n.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import i18n from "i18next";
|
|
2
2
|
import { initReactI18next } from "react-i18next";
|
|
3
3
|
import vi from "./vi/common.json";
|
|
4
|
-
import
|
|
4
|
+
import viConversationInbox from "./vi/conversation-inbox.json";
|
|
5
5
|
|
|
6
6
|
if (!i18n.isInitialized) {
|
|
7
7
|
i18n.use(initReactI18next).init({
|
|
8
8
|
resources: {
|
|
9
|
-
vi: { common: vi, "
|
|
9
|
+
vi: { common: vi, "conversation-inbox": viConversationInbox },
|
|
10
10
|
},
|
|
11
11
|
lng: "vi",
|
|
12
12
|
fallbackLng: "vi",
|
|
13
13
|
interpolation: { escapeValue: false },
|
|
14
|
-
ns: ["common", "
|
|
14
|
+
ns: ["common", "conversation-inbox"],
|
|
15
15
|
defaultNS: "common",
|
|
16
16
|
});
|
|
17
17
|
}
|