@droppii-org/chat-sdk 0.1.53 → 0.1.55
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-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 +3 -18
- 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/message/footer/index.d.ts.map +1 -1
- package/dist/components/message/footer/index.js +0 -1
- package/dist/components/message/item/LinkCard.d.ts +2 -1
- package/dist/components/message/item/LinkCard.d.ts.map +1 -1
- package/dist/components/message/item/LinkCard.js +5 -3
- package/dist/components/message/item/UrlTextMessage.d.ts.map +1 -1
- package/dist/components/message/item/UrlTextMessage.js +10 -7
- 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/constants/botFlow.d.ts +0 -5
- package/dist/constants/botFlow.d.ts.map +1 -1
- package/dist/constants/botFlow.js +0 -11
- 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/message/useMessage.d.ts.map +1 -1
- package/dist/hooks/message/useMessage.js +0 -2
- package/dist/hooks/message/useSendMessage.d.ts +5 -3
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +8 -3
- package/dist/screens/biz-thread-detail/index.d.ts.map +1 -1
- package/dist/screens/biz-thread-detail/index.js +4 -8
- 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 -1
- package/dist/types/chat.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface BizMessageListProps {
|
|
3
|
+
bottomSlot?: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
declare const BizMessageList: ({ bottomSlot }: BizMessageListProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
6
|
export default BizMessageList;
|
|
3
7
|
//# sourceMappingURL=BizMessageList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAclD,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB;AAED,QAAA,MAAM,cAAc,GAAI,gBAAgB,mBAAmB,4CA0E1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { Empty, Spin } from "antd";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
@@ -11,15 +11,11 @@ import useBizConversationStore from "../../store/bizConversation";
|
|
|
11
11
|
import useConversationStore from "../../store/conversation";
|
|
12
12
|
import useAuthStore from "../../store/auth";
|
|
13
13
|
import { isBizGroupChat } from "../../utils/bizConversation";
|
|
14
|
-
import { buildBotButtonsMessage } from "../../constants/botFlow";
|
|
15
14
|
import emitter from "../../utils/events";
|
|
16
15
|
import MessageItem from "../../components/message/item";
|
|
17
|
-
|
|
18
|
-
const BizMessageList = () => {
|
|
19
|
-
var _a, _b;
|
|
16
|
+
const BizMessageList = ({ bottomSlot }) => {
|
|
20
17
|
const { t } = useTranslation("biz-inbox");
|
|
21
18
|
const { user } = useChatContext();
|
|
22
|
-
const { buttons, disabled } = useBotFlowContext();
|
|
23
19
|
const authUserID = useAuthStore((state) => state.userID);
|
|
24
20
|
const conversation = useBizConversationStore((state) => state.conversationData);
|
|
25
21
|
const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
|
|
@@ -29,23 +25,12 @@ const BizMessageList = () => {
|
|
|
29
25
|
const { scrollRef, loadMoreOldMessage, handleInfiniteScroll, scrollToBottomIfAtBottom, } = useMessageListScroll(Object.assign({ conversationId, userId: (user === null || user === void 0 ? void 0 : user.userID) || authUserID }, messageController));
|
|
30
26
|
const { loadState, moreOldLoading } = messageController;
|
|
31
27
|
const isMessageLoading = !conversationId || loadState.initLoading;
|
|
32
|
-
const botSenderId = ((_a = loadState.messageList.find((message) => message.sendID !== authUserID)) === null || _a === void 0 ? void 0 : _a.sendID) ||
|
|
33
|
-
((_b = conversation === null || conversation === void 0 ? void 0 : conversation.peer) === null || _b === void 0 ? void 0 : _b.id) ||
|
|
34
|
-
"";
|
|
35
|
-
const botButtonsMessage = buttons.length > 0 && !disabled
|
|
36
|
-
? buildBotButtonsMessage({
|
|
37
|
-
sendID: botSenderId,
|
|
38
|
-
})
|
|
39
|
-
: null;
|
|
40
|
-
const renderedMessages = botButtonsMessage
|
|
41
|
-
? [botButtonsMessage, ...loadState.messageList]
|
|
42
|
-
: loadState.messageList;
|
|
43
28
|
useEffect(() => {
|
|
44
29
|
emitter.on("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
|
|
45
30
|
return () => {
|
|
46
31
|
emitter.off("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
|
|
47
32
|
};
|
|
48
33
|
}, [scrollToBottomIfAtBottom]);
|
|
49
|
-
return (_jsx("div", { "data-testid": "biz-message-list", className: "relative flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-white", children: isMessageLoading ? (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) })) : (
|
|
34
|
+
return (_jsx("div", { "data-testid": "biz-message-list", className: "relative flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-white", children: isMessageLoading ? (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) })) : (_jsxs(MessageInfiniteScroll, { scrollRef: scrollRef, scrollableTargetId: "scrollableBizMessagesDiv", loadState: loadState, moreOldLoading: moreOldLoading, onLoadMoreOld: loadMoreOldMessage, onScroll: handleInfiniteScroll, containerClassName: "h-full", empty: _jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Empty, { description: t("empty.no_messages") }) }), children: [bottomSlot, loadState.messageList.map((message, index, array) => (_jsx(MessageItem, { message: message, allMessages: array, isGroupChat: isGroupChat, forceHideTip: index === 0 && !!bottomSlot }, message.clientMsgID)))] })) }));
|
|
50
35
|
};
|
|
51
36
|
export default BizMessageList;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { BotButtonOption } from "../../../types/biz";
|
|
2
|
+
export interface BotButtonMessageProps {
|
|
3
|
+
buttons: BotButtonOption[];
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
onSelect: (actionId: string) => void;
|
|
6
|
+
onRestart: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const BotButtonMessage: ({ buttons, disabled, onSelect, onRestart, }: BotButtonMessageProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
2
9
|
export default BotButtonMessage;
|
|
3
10
|
//# sourceMappingURL=BotButtonMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotButtonMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/BotButtonMessage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BotButtonMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/BotButtonMessage.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,gBAAgB,GAAI,6CAKvB,qBAAqB,mDA4EvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -3,12 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import { Icon } from "../../../components/icon";
|
|
6
|
+
import MessageBubble from "../../../components/message/item/MessageBubble";
|
|
6
7
|
import { BOT_BUTTON_MENU_THRESHOLD, BOT_DEFAULT_BUTTON_ID, } from "../../../constants/botFlow";
|
|
7
|
-
import { useBotFlowContext } from "./BotFlowContext";
|
|
8
8
|
const CHEVRON_SIZE = 20;
|
|
9
|
-
const BotButtonMessage = () => {
|
|
9
|
+
const BotButtonMessage = ({ buttons, disabled, onSelect, onRestart, }) => {
|
|
10
10
|
const { t } = useTranslation("biz-inbox");
|
|
11
|
-
|
|
11
|
+
if (buttons.length === 0)
|
|
12
|
+
return null;
|
|
12
13
|
const isMenuStyle = buttons.length > BOT_BUTTON_MENU_THRESHOLD;
|
|
13
14
|
const handleSelect = (actionId) => {
|
|
14
15
|
if (disabled)
|
|
@@ -24,6 +25,6 @@ const BotButtonMessage = () => {
|
|
|
24
25
|
: option.label }), _jsx(Icon, { icon: "angle-right-o", size: CHEVRON_SIZE, className: "text-gray-900" })] }, option.id))) })) : (_jsx("div", { className: "flex flex-col gap-2", children: buttons.map((option) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex flex-1 items-center justify-center gap-2 rounded-lg border border-primary-400 bg-primary-25 px-3 py-2", "text-center text-[14px] font-[510] leading-[160%] text-primary-400 transition-colors", disabled && "cursor-not-allowed opacity-60"), children: _jsx("span", { children: option.id === BOT_DEFAULT_BUTTON_ID
|
|
25
26
|
? t("thread_detail.bot.restart")
|
|
26
27
|
: option.label }) }, option.id))) }));
|
|
27
|
-
return optionsNode;
|
|
28
|
+
return (_jsx("div", { className: "flex min-w-0 flex-col gap-2 px-3 py-1 sm:px-4", children: _jsx("div", { className: "flex min-w-0 items-end justify-start pl-3 pr-12", children: _jsx("div", { className: "flex min-w-0 max-w-[75%] flex-col items-start", children: _jsx(MessageBubble, { isMine: false, content: optionsNode }) }) }) }));
|
|
28
29
|
};
|
|
29
30
|
export default BotButtonMessage;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { default as BotStartButton } from "./BotStartButton";
|
|
2
2
|
export type { BotStartButtonProps } from "./BotStartButton";
|
|
3
3
|
export { default as BotButtonMessage } from "./BotButtonMessage";
|
|
4
|
-
export {
|
|
5
|
-
export type { BotFlowContextValue } from "./BotFlowContext";
|
|
4
|
+
export type { BotButtonMessageProps } from "./BotButtonMessage";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAEL,wBAAwB,EAEzB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB/C,UAAU,kBAAkB;IAC1B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AASD,eAAO,MAAM,oBAAoB,mDAY/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAyC,CAAC;AAE9E,QAAA,MAAM,qBAAqB,GAAI,4CAG5B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAEL,wBAAwB,EAEzB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB/C,UAAU,kBAAkB;IAC1B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AASD,eAAO,MAAM,oBAAoB,mDAY/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAyC,CAAC;AAE9E,QAAA,MAAM,qBAAqB,GAAI,4CAG5B,kBAAkB,4CAsSpB,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -80,7 +80,6 @@ const MessageFooterProvider = ({ currentSession, openCreateCannedModal, }) => {
|
|
|
80
80
|
if (!showLinkPreview || !previewUrl || !previewMetadata)
|
|
81
81
|
return undefined;
|
|
82
82
|
return {
|
|
83
|
-
url: previewUrl,
|
|
84
83
|
title: previewMetadata.title,
|
|
85
84
|
description: previewMetadata.description,
|
|
86
85
|
image: previewMetadata.image,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { UrlMetadataInfo } from "../../../types/chat";
|
|
2
2
|
export interface LinkCardProps {
|
|
3
3
|
metadata: UrlMetadataInfo;
|
|
4
|
+
url?: string;
|
|
4
5
|
}
|
|
5
|
-
declare const LinkCard: ({ metadata }: LinkCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
declare const LinkCard: ({ metadata, url }: LinkCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
7
|
export default LinkCard;
|
|
7
8
|
//# sourceMappingURL=LinkCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkCard.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/LinkCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"LinkCard.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/LinkCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,QAAQ,GAAI,mBAAmB,aAAa,mDA6CjD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -3,15 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import { getHostLabel } from "../../../utils/link";
|
|
5
5
|
import { openLink } from "../../../utils/openLink";
|
|
6
|
-
const LinkCard = ({ metadata }) => {
|
|
6
|
+
const LinkCard = ({ metadata, url }) => {
|
|
7
7
|
const { t } = useTranslation("biz-inbox");
|
|
8
|
-
const {
|
|
8
|
+
const { title, description, image } = metadata;
|
|
9
9
|
if (!title && !description && !image) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
const handleOpen = () => {
|
|
13
|
+
if (!url)
|
|
14
|
+
return;
|
|
13
15
|
openLink(url, t);
|
|
14
16
|
};
|
|
15
|
-
return (_jsxs("button", { type: "button", onClick: handleOpen, "data-testid": "link-message-card", className: "flex w-full max-w-[292px] flex-col overflow-hidden rounded-[12px] border border-gray-900/10 bg-white text-left", children: [image && (_jsx("div", { className: "aspect-[16/9] w-full overflow-hidden", children: _jsx("img", { src: image, alt: "", className: "h-full w-full object-cover" }) })), _jsxs("div", { className: "flex flex-col px-3 py-2", children: [title && (_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-gray-900", children: title })), _jsx("p", { className: "truncate text-[12px] font-medium leading-[1.6] tracking-[0.12px] text-primary-400", children: getHostLabel(url) }), description && (_jsx("p", { className: "line-clamp-2 text-[12px] leading-[1.6] text-gray-600", children: description }))] })] }));
|
|
17
|
+
return (_jsxs("button", { type: "button", onClick: handleOpen, "data-testid": "link-message-card", className: "flex w-full max-w-[292px] flex-col overflow-hidden rounded-[12px] border border-gray-900/10 bg-white text-left", children: [image && (_jsx("div", { className: "aspect-[16/9] w-full overflow-hidden", children: _jsx("img", { src: image, alt: "", className: "h-full w-full object-cover" }) })), _jsxs("div", { className: "flex flex-col px-3 py-2", children: [title && (_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-gray-900", children: title })), url && (_jsx("p", { className: "truncate text-[12px] font-medium leading-[1.6] tracking-[0.12px] text-primary-400", children: getHostLabel(url) })), description && (_jsx("p", { className: "line-clamp-2 text-[12px] leading-[1.6] text-gray-600", children: description }))] })] }));
|
|
16
18
|
};
|
|
17
19
|
export default LinkCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlTextMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/UrlTextMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAatD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,
|
|
1
|
+
{"version":3,"file":"UrlTextMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/UrlTextMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAatD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,4CAuEzD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import LinkText from "./LinkText";
|
|
|
6
6
|
import LinkCard from "./LinkCard";
|
|
7
7
|
import { MESSAGE_TEXT_CLASS } from "./textStyle";
|
|
8
8
|
const UrlTextMessageItem = (props) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
10
10
|
const { message } = props;
|
|
11
11
|
let extendMessageInfo = null;
|
|
12
12
|
try {
|
|
@@ -17,18 +17,21 @@ const UrlTextMessageItem = (props) => {
|
|
|
17
17
|
console.error("Failed to parse extendMessageInfo", error);
|
|
18
18
|
}
|
|
19
19
|
const richHtmlContent = ((_b = (_a = extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.messageInfo) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content) || "";
|
|
20
|
+
const urlMetadata = extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.urlMetadata;
|
|
21
|
+
const metadataUrl = (_d = (_c = message === null || message === void 0 ? void 0 : message.urlTextElem) === null || _c === void 0 ? void 0 : _c.urls) === null || _d === void 0 ? void 0 : _d[0];
|
|
22
|
+
const hasUrlMetadata = !!(urlMetadata &&
|
|
23
|
+
(urlMetadata.title || urlMetadata.description || urlMetadata.image));
|
|
20
24
|
if (richHtmlContent && htmlHasFormatting(richHtmlContent)) {
|
|
21
25
|
const sanitizedContent = sanitizeHtml(wrapLinksInHtml(richHtmlContent));
|
|
22
|
-
return (_jsx("div", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, dangerouslySetInnerHTML: { __html: sanitizedContent } }));
|
|
26
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, dangerouslySetInnerHTML: { __html: sanitizedContent } }), hasUrlMetadata && urlMetadata && (_jsx(LinkCard, { metadata: urlMetadata, url: metadataUrl }))] }));
|
|
23
27
|
}
|
|
24
|
-
const text = (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return (_jsxs("div", { className: "flex max-w-[292px] flex-col gap-2", children: [text && _jsx(LinkText, { text: text }), _jsx(LinkCard, { metadata: urlMetadata })] }));
|
|
28
|
+
const text = (_k = (_j = (_h = (_f = (_e = message === null || message === void 0 ? void 0 : message.textElem) === null || _e === void 0 ? void 0 : _e.content) !== null && _f !== void 0 ? _f : (_g = message === null || message === void 0 ? void 0 : message.urlTextElem) === null || _g === void 0 ? void 0 : _g.content) !== null && _h !== void 0 ? _h : message === null || message === void 0 ? void 0 : message.content) !== null && _j !== void 0 ? _j : stripHtml(richHtmlContent)) !== null && _k !== void 0 ? _k : "";
|
|
29
|
+
if (hasUrlMetadata && urlMetadata) {
|
|
30
|
+
return (_jsxs("div", { className: "flex max-w-[292px] flex-col gap-2", children: [text && _jsx(LinkText, { text: text }), _jsx(LinkCard, { metadata: urlMetadata, url: metadataUrl })] }));
|
|
28
31
|
}
|
|
29
32
|
if (text) {
|
|
30
33
|
return _jsx(LinkText, { text: text });
|
|
31
34
|
}
|
|
32
|
-
return (_jsx("span", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, children: ((
|
|
35
|
+
return (_jsx("span", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, children: ((_m = (_l = message === null || message === void 0 ? void 0 : message.urlTextElem) === null || _l === void 0 ? void 0 : _l.urls) === null || _m === void 0 ? void 0 : _m[0]) || "" }));
|
|
33
36
|
};
|
|
34
37
|
export default UrlTextMessageItem;
|
|
@@ -3,12 +3,13 @@ interface MessageItemProps {
|
|
|
3
3
|
message: MessageItemType;
|
|
4
4
|
allMessages: MessageItemType[];
|
|
5
5
|
isGroupChat?: boolean;
|
|
6
|
+
forceHideTip?: boolean;
|
|
6
7
|
contextMenuOpen?: boolean;
|
|
7
8
|
onContextMenuOpenChange?: (open: boolean) => void;
|
|
8
9
|
onRevokeMessage?: (clientMsgID: string) => void;
|
|
9
10
|
onQuoteMessage?: (message: MessageItemType) => void;
|
|
10
11
|
onPressQuoteMessage?: (clientMsgID: string) => void;
|
|
11
12
|
}
|
|
12
|
-
declare const MessageItem: ({ message, allMessages, isGroupChat, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
declare const MessageItem: ({ message, allMessages, isGroupChat, forceHideTip, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
14
|
export default MessageItem;
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,yBAAyB,CAAC;AA6BjC,UAAU,gBAAgB;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAeD,QAAA,MAAM,WAAW,GAAI,sJAUlB,gBAAgB,mDA+QlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -25,10 +25,8 @@ import RevokeMessageItem from "./RevokeMessage";
|
|
|
25
25
|
import QuoteMessageItem from "./QuoteMessage";
|
|
26
26
|
import SystemLogMessageItem from "./SystemLogMessage";
|
|
27
27
|
import { isSystemLogMessageType } from "../../../utils/messageLog";
|
|
28
|
-
import { BOT_BUTTONS_MESSAGE_TYPE } from "../../../constants/botFlow";
|
|
29
|
-
import BotButtonMessage from "../../../components/biz-thread-detail/bot/BotButtonMessage";
|
|
30
28
|
const MessageAvatar = ({ avatarUrl }) => avatarUrl ? (_jsx("img", { src: avatarUrl, alt: "", className: "h-6 w-6 shrink-0 self-end rounded-full object-cover" })) : (_jsx("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center self-end rounded-full bg-chat-avatar", children: _jsx(Icon, { icon: "droppii-o-1", size: 14, className: "text-white" }) }));
|
|
31
|
-
const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }) => {
|
|
29
|
+
const MessageItem = ({ message, allMessages, isGroupChat = false, forceHideTip = false, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }) => {
|
|
32
30
|
var _a;
|
|
33
31
|
const { t } = useTranslation();
|
|
34
32
|
const { resendMessage } = useSendMessage();
|
|
@@ -54,8 +52,6 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
|
|
|
54
52
|
return _jsx(SystemLogMessageItem, { message: item });
|
|
55
53
|
case MessageType.RevokeMessage:
|
|
56
54
|
return _jsx(RevokeMessageItem, {});
|
|
57
|
-
case BOT_BUTTONS_MESSAGE_TYPE:
|
|
58
|
-
return _jsx(BotButtonMessage, {});
|
|
59
55
|
default:
|
|
60
56
|
return _jsx(TextMessageItem, { message: item });
|
|
61
57
|
}
|
|
@@ -73,7 +69,6 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
|
|
|
73
69
|
}, [userID, message]);
|
|
74
70
|
const contextMenuItems = useMemo(() => {
|
|
75
71
|
if ((message === null || message === void 0 ? void 0 : message.contentType) === MessageType.RevokeMessage ||
|
|
76
|
-
(message === null || message === void 0 ? void 0 : message.contentType) === BOT_BUTTONS_MESSAGE_TYPE ||
|
|
77
72
|
isSystemLogMessageType(message === null || message === void 0 ? void 0 : message.contentType)) {
|
|
78
73
|
return [];
|
|
79
74
|
}
|
|
@@ -132,7 +127,7 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
|
|
|
132
127
|
const showPeerInfo = isGroupChat || showSenderInfo;
|
|
133
128
|
const showAvatar = showPeerInfo && !isMine && !nextSameUser;
|
|
134
129
|
const showSenderName = showPeerInfo && !isMine && !prevSameUser;
|
|
135
|
-
const showTip = !nextSameUser;
|
|
130
|
+
const showTip = forceHideTip ? false : !nextSameUser;
|
|
136
131
|
if (!isCrm && isInternalMessage) {
|
|
137
132
|
return null;
|
|
138
133
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { MessageItem, MessageType } from "@openim/wasm-client-sdk";
|
|
2
1
|
export declare const BOT_DEFAULT_BUTTON_ID = "default-item-button";
|
|
3
2
|
export declare const BOT_BUTTON_MENU_THRESHOLD = 3;
|
|
4
|
-
export declare const BOT_BUTTONS_MESSAGE_TYPE: MessageType;
|
|
5
|
-
export declare const buildBotButtonsMessage: ({ sendID, }: {
|
|
6
|
-
sendID: string;
|
|
7
|
-
}) => MessageItem;
|
|
8
3
|
//# sourceMappingURL=botFlow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"botFlow.d.ts","sourceRoot":"","sources":["../../src/constants/botFlow.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"botFlow.d.ts","sourceRoot":"","sources":["../../src/constants/botFlow.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,eAAO,MAAM,yBAAyB,IAAI,CAAC"}
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import { MessageStatus, } from "@openim/wasm-client-sdk";
|
|
2
1
|
export const BOT_DEFAULT_BUTTON_ID = "default-item-button";
|
|
3
2
|
export const BOT_BUTTON_MENU_THRESHOLD = 3;
|
|
4
|
-
export const BOT_BUTTONS_MESSAGE_TYPE = 990001;
|
|
5
|
-
export const buildBotButtonsMessage = ({ sendID, }) => ({
|
|
6
|
-
clientMsgID: "bot-buttons",
|
|
7
|
-
contentType: BOT_BUTTONS_MESSAGE_TYPE,
|
|
8
|
-
sendID,
|
|
9
|
-
sendTime: Date.now(),
|
|
10
|
-
status: MessageStatus.Succeed,
|
|
11
|
-
isInternal: false,
|
|
12
|
-
ex: "",
|
|
13
|
-
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type BotInputButtonsBlock } from "../../types/biz";
|
|
2
|
-
export type BotFlowStatus = "
|
|
2
|
+
export type BotFlowStatus = "running" | "not_started";
|
|
3
3
|
interface UseBotFlowParams {
|
|
4
4
|
conversationId: string;
|
|
5
5
|
isBotThread: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare const useBotFlow: ({ conversationId, isBotThread, }: UseBotFlowParams) => {
|
|
8
|
-
status:
|
|
8
|
+
status: BotFlowStatus;
|
|
9
9
|
isProcessing: boolean;
|
|
10
|
+
shouldShowButtons: boolean;
|
|
10
11
|
currentButtonsBlock: BotInputButtonsBlock | null;
|
|
11
12
|
start: () => Promise<void>;
|
|
12
13
|
selectButton: (actionId: string) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBotFlow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBotFlow.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,aAAa,CAAC;AAEtD,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB;AAoBD,eAAO,MAAM,UAAU,GAAI,kCAGxB,gBAAgB;;;;;;6BAoGqB,MAAM;;CAqC7C,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { BotBlockType, BotFlowNodeType, } from "../../types/biz";
|
|
4
|
+
import { useSendMessage } from "../../hooks/message/useSendMessage";
|
|
5
|
+
import useAuthStore from "../../store/auth";
|
|
6
|
+
import emitter from "../../utils/events";
|
|
4
7
|
import { useConversationDetail } from "./useConversationDetail";
|
|
5
8
|
import { useRunBotFlow } from "./useRunBotFlow";
|
|
6
9
|
import { useResetBotFlow } from "./useResetBotFlow";
|
|
@@ -8,16 +11,33 @@ const INITIAL_BOT_FLOW_STATE = {
|
|
|
8
11
|
conversationId: "",
|
|
9
12
|
flowCurrentStep: null,
|
|
10
13
|
};
|
|
14
|
+
const parseMessageFlowGroupId = (ex) => {
|
|
15
|
+
var _a;
|
|
16
|
+
try {
|
|
17
|
+
return (_a = JSON.parse(ex || "{}").flow) === null || _a === void 0 ? void 0 : _a.groupId;
|
|
18
|
+
}
|
|
19
|
+
catch (_b) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
11
23
|
export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
12
24
|
var _a;
|
|
13
25
|
const [botFlowState, setBotFlowState] = useState(INITIAL_BOT_FLOW_STATE);
|
|
14
|
-
const { conversationId: storedConversationId, flowCurrentStep
|
|
26
|
+
const { conversationId: storedConversationId, flowCurrentStep } = botFlowState;
|
|
27
|
+
const [pendingGroupId, setPendingGroupId] = useState(null);
|
|
28
|
+
const latestBotFlowGroupIdRef = useRef(null);
|
|
29
|
+
const authUserID = useAuthStore((state) => state.userID);
|
|
15
30
|
const detailQuery = useConversationDetail(conversationId, isBotThread);
|
|
16
31
|
const runMutation = useRunBotFlow();
|
|
17
32
|
const resetMutation = useResetBotFlow();
|
|
33
|
+
const { sendMergeMessage } = useSendMessage({
|
|
34
|
+
scrollEvent: "BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM",
|
|
35
|
+
});
|
|
18
36
|
useEffect(() => {
|
|
19
37
|
if (!isBotThread) {
|
|
20
38
|
setBotFlowState(INITIAL_BOT_FLOW_STATE);
|
|
39
|
+
setPendingGroupId(null);
|
|
40
|
+
latestBotFlowGroupIdRef.current = null;
|
|
21
41
|
return;
|
|
22
42
|
}
|
|
23
43
|
if (detailQuery.data) {
|
|
@@ -25,13 +45,32 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
|
25
45
|
conversationId,
|
|
26
46
|
flowCurrentStep: detailQuery.data.flowCurrentStep,
|
|
27
47
|
});
|
|
48
|
+
setPendingGroupId(null);
|
|
49
|
+
latestBotFlowGroupIdRef.current = null;
|
|
28
50
|
}
|
|
29
51
|
}, [isBotThread, conversationId, detailQuery.data]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const handleNewMessage = (message) => {
|
|
54
|
+
if (message.sendID === authUserID)
|
|
55
|
+
return;
|
|
56
|
+
const groupId = parseMessageFlowGroupId(message.ex);
|
|
57
|
+
if (!groupId)
|
|
58
|
+
return;
|
|
59
|
+
latestBotFlowGroupIdRef.current = groupId;
|
|
60
|
+
setPendingGroupId((currentGroupId) => currentGroupId === groupId ? null : currentGroupId);
|
|
61
|
+
};
|
|
62
|
+
emitter.on("PUSH_NEW_MSG", handleNewMessage);
|
|
63
|
+
return () => {
|
|
64
|
+
emitter.off("PUSH_NEW_MSG", handleNewMessage);
|
|
65
|
+
};
|
|
66
|
+
}, [authUserID]);
|
|
30
67
|
const activeStep = storedConversationId === conversationId ? flowCurrentStep : null;
|
|
31
68
|
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;
|
|
32
69
|
const isProcessing = runMutation.isPending || resetMutation.isPending;
|
|
70
|
+
const shouldShowButtons = !!currentButtonsBlock && !isProcessing && !pendingGroupId;
|
|
33
71
|
const status = (activeStep === null || activeStep === void 0 ? void 0 : activeStep.type) === BotFlowNodeType.Start ? "not_started" : "running";
|
|
34
72
|
const runStep = async (step, actionId = null) => {
|
|
73
|
+
latestBotFlowGroupIdRef.current = null;
|
|
35
74
|
const result = await runMutation.mutateAsync({
|
|
36
75
|
conversationId,
|
|
37
76
|
groupId: step.id,
|
|
@@ -42,6 +81,11 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
|
42
81
|
conversationId,
|
|
43
82
|
flowCurrentStep: result.flowNextStep,
|
|
44
83
|
});
|
|
84
|
+
const nextGroupId = result.flowNextStep.id;
|
|
85
|
+
setPendingGroupId(result.havingBotMessage &&
|
|
86
|
+
latestBotFlowGroupIdRef.current !== nextGroupId
|
|
87
|
+
? nextGroupId
|
|
88
|
+
: null);
|
|
45
89
|
};
|
|
46
90
|
const start = async () => {
|
|
47
91
|
if (!activeStep)
|
|
@@ -51,6 +95,20 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
|
51
95
|
const selectButton = async (actionId) => {
|
|
52
96
|
if (!activeStep)
|
|
53
97
|
return;
|
|
98
|
+
const flow = {
|
|
99
|
+
groupId: activeStep.id,
|
|
100
|
+
childId: null,
|
|
101
|
+
actionId,
|
|
102
|
+
};
|
|
103
|
+
const selectedButton = currentButtonsBlock === null || currentButtonsBlock === void 0 ? void 0 : currentButtonsBlock.data.buttons.find((button) => button.id === actionId);
|
|
104
|
+
if (selectedButton) {
|
|
105
|
+
await sendMergeMessage({
|
|
106
|
+
plainText: selectedButton.label,
|
|
107
|
+
richText: "",
|
|
108
|
+
isInternal: false,
|
|
109
|
+
flow,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
54
112
|
await runStep(activeStep, actionId);
|
|
55
113
|
};
|
|
56
114
|
const restart = async () => {
|
|
@@ -60,6 +118,7 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
|
60
118
|
return {
|
|
61
119
|
status,
|
|
62
120
|
isProcessing,
|
|
121
|
+
shouldShowButtons,
|
|
63
122
|
currentButtonsBlock,
|
|
64
123
|
start,
|
|
65
124
|
selectButton,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { BotFlowMeta } from "../../types/chat";
|
|
2
|
+
import type { RunBotFlowResponse } from "../../types/biz";
|
|
3
|
+
export interface RunBotFlowParams extends BotFlowMeta {
|
|
3
4
|
conversationId: string;
|
|
4
5
|
}
|
|
5
6
|
export declare const useRunBotFlow: () => import("@tanstack/react-query").UseMutationResult<RunBotFlowResponse, Error, RunBotFlowParams, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRunBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useRunBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"useRunBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useRunBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,aAAa,+GAgBzB,CAAC"}
|
|
@@ -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: {
|
|
@@ -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,eAAe,EACf,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQlC,OAAO,EAAgB,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAkBpF,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,YAE0C,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,gCActE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,eAAe,WAAW,gCAc3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,4BAA4B,GAC5B,wCAAwC,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,eAAe,CAAC;CACxE;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,qBAAqB;
|
|
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,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQlC,OAAO,EAAgB,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAkBpF,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,YAE0C,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,gCActE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,eAAe,WAAW,gCAc3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,4BAA4B,GAC5B,wCAAwC,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,eAAe,CAAC;CACxE;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,qBAAqB;uGAiPvD;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;QAClC,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,eAAe,CAAC;QAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;KACpB,KAAG,OAAO,CAAC,OAAO,CAAC;mCAxHE,WAAW;CA8SpC,CAAC;AAEF,eAAO,MAAM,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 = {
|
|
@@ -455,7 +459,8 @@ export const generateExtendMessageInfo = ({ richText, urlMetadata, currentSessio
|
|
|
455
459
|
},
|
|
456
460
|
};
|
|
457
461
|
}
|
|
458
|
-
if (urlMetadata
|
|
462
|
+
if (urlMetadata &&
|
|
463
|
+
(urlMetadata.title || urlMetadata.description || urlMetadata.image)) {
|
|
459
464
|
extendMessageInfo.urlMetadata = urlMetadata;
|
|
460
465
|
}
|
|
461
466
|
return extendMessageInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/biz-thread-detail/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAQhF,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,oBAAoB,GAAI,gDAK3B,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/biz-thread-detail/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAQhF,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,oBAAoB,GAAI,gDAK3B,yBAAyB,mDAmE3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|