@droppii-org/chat-sdk 0.1.38 → 0.1.40

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.
Files changed (33) hide show
  1. package/dist/components/biz-inbox/BizThreadAvatar.d.ts +3 -2
  2. package/dist/components/biz-inbox/BizThreadAvatar.d.ts.map +1 -1
  3. package/dist/components/biz-inbox/BizThreadAvatar.js +5 -9
  4. package/dist/components/biz-inbox/BizThreadCard.d.ts.map +1 -1
  5. package/dist/components/biz-inbox/BizThreadCard.js +2 -2
  6. package/dist/components/biz-inbox/BizThreadList.d.ts.map +1 -1
  7. package/dist/components/biz-inbox/BizThreadList.js +11 -6
  8. package/dist/components/biz-inbox/BizThreadTitle.d.ts +3 -2
  9. package/dist/components/biz-inbox/BizThreadTitle.d.ts.map +1 -1
  10. package/dist/components/biz-inbox/BizThreadTitle.js +5 -2
  11. package/dist/components/biz-thread-detail/BizMessageList.d.ts.map +1 -1
  12. package/dist/components/biz-thread-detail/BizMessageList.js +2 -4
  13. package/dist/components/biz-thread-detail/BizThreadDetailHeader.d.ts.map +1 -1
  14. package/dist/components/biz-thread-detail/BizThreadDetailHeader.js +2 -2
  15. package/dist/context/ChatContext.d.ts.map +1 -1
  16. package/dist/context/ChatContext.js +24 -20
  17. package/dist/hooks/biz/useBizActiveConversation.d.ts.map +1 -1
  18. package/dist/hooks/biz/useBizActiveConversation.js +9 -7
  19. package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
  20. package/dist/hooks/global/useGlobalEvent.js +5 -3
  21. package/dist/hooks/message/useMessage.d.ts.map +1 -1
  22. package/dist/hooks/message/useMessage.js +67 -35
  23. package/dist/screens/desk-message/index.d.ts.map +1 -1
  24. package/dist/screens/desk-message/index.js +3 -3
  25. package/dist/styles/global.css +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/types/biz.d.ts +2 -1
  28. package/dist/types/biz.d.ts.map +1 -1
  29. package/dist/types/biz.js +1 -0
  30. package/dist/utils/bizConversation.d.ts +8 -4
  31. package/dist/utils/bizConversation.d.ts.map +1 -1
  32. package/dist/utils/bizConversation.js +39 -8
  33. package/package.json +1 -1
@@ -1,10 +1,11 @@
1
- import { BizChatCategory } from "../../types/biz";
1
+ import { BizChatCategory, BizPeerType } from "../../types/biz";
2
2
  export interface BizThreadAvatarProps {
3
+ peerType: BizPeerType;
3
4
  chatCategory: BizChatCategory;
4
5
  displayName: string;
5
6
  avatarUrl: string | null;
6
7
  badgeLabel: string;
7
8
  }
8
- declare const BizThreadAvatar: ({ chatCategory, displayName, avatarUrl, badgeLabel, }: BizThreadAvatarProps) => import("react/jsx-runtime").JSX.Element;
9
+ declare const BizThreadAvatar: ({ peerType, chatCategory, displayName, avatarUrl, badgeLabel, }: BizThreadAvatarProps) => import("react/jsx-runtime").JSX.Element;
9
10
  export default BizThreadAvatar;
10
11
  //# sourceMappingURL=BizThreadAvatar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BizThreadAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadAvatar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,GAAI,uDAKtB,oBAAoB,4CAoDtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"BizThreadAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadAvatar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG3D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,GAAI,iEAMtB,oBAAoB,4CAmCtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -2,15 +2,11 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import { Icon } from "../../components/icon";
5
- import { BizChatCategory } from "../../types/biz";
5
+ import { BizChatCategory, BizPeerType } from "../../types/biz";
6
6
  import { resolveBizBadgeColor } from "../../utils/bizConversation";
7
- const BizThreadAvatar = ({ chatCategory, displayName, avatarUrl, badgeLabel, }) => {
8
- if (chatCategory === BizChatCategory.BIZ_BOT_CRM) {
9
- if (avatarUrl) {
10
- return (_jsx("div", { className: "relative h-12 w-12 shrink-0", children: _jsx("img", { src: avatarUrl, alt: displayName, className: "h-12 w-12 rounded-xl object-cover" }) }));
11
- }
12
- return (_jsx("div", { className: "flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-[#607CFB] p-2.5 shadow-[inset_2px_3px_8px_0_rgba(0,0,0,0.40)]", children: _jsx(Icon, { icon: "head-phone-o1", size: 28, className: "text-white" }) }));
13
- }
14
- return (_jsxs("div", { className: "relative h-12 w-12 shrink-0", children: [avatarUrl ? (_jsx("img", { src: avatarUrl, alt: displayName, className: "h-12 w-12 rounded-full object-cover" })) : (_jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-[#0C5CFF] text-white", children: chatCategory === BizChatCategory.GROUP ? (_jsx(Icon, { icon: "user-two-b", size: 20 })) : chatCategory === BizChatCategory.BIZ_BOT_PDP ? (_jsx(Icon, { icon: "droppii-o-1", size: 20 })) : (_jsx(Icon, { icon: "user-o", size: 20 })) })), badgeLabel && (_jsx("span", { className: clsx("absolute -bottom-px -right-px flex h-[17px] items-center justify-center gap-2 rounded-md border border-white px-1 text-[10px] font-semibold leading-3 text-white shadow-[inset_2px_6px_8px_0_rgba(0,0,0,0.40)]", resolveBizBadgeColor(chatCategory)), children: badgeLabel }))] }));
7
+ const BizThreadAvatar = ({ peerType, chatCategory, displayName, avatarUrl, badgeLabel, }) => {
8
+ const badge = badgeLabel ? (_jsx("span", { className: clsx("absolute -bottom-px -right-px flex h-[17px] items-center justify-center gap-2 rounded-md border border-white px-1 text-[10px] font-semibold leading-3 text-white shadow-[inset_2px_6px_8px_0_rgba(0,0,0,0.40)]", resolveBizBadgeColor(peerType)), children: badgeLabel })) : null;
9
+ return (_jsxs("div", { className: "relative h-12 w-12 shrink-0", children: [avatarUrl ? (_jsx("img", { src: avatarUrl, alt: displayName, className: "h-12 w-12 rounded-full object-cover" })) : (_jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-[#0C5CFF] text-white", children: chatCategory === BizChatCategory.GROUP ||
10
+ peerType === BizPeerType.GROUP ? (_jsx(Icon, { icon: "user-two-b", size: 20 })) : peerType === BizPeerType.BOT ? (_jsx(Icon, { icon: "droppii-o-1", size: 20 })) : (_jsx(Icon, { icon: "user-o", size: 20 })) })), badge] }));
15
11
  };
16
12
  export default BizThreadAvatar;
@@ -1 +1 @@
1
- {"version":3,"file":"BizThreadCard.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAYvF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAClD;AAwBD,QAAA,MAAM,aAAa,GAAI,mBAAmB,kBAAkB,4CA+D3D,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"BizThreadCard.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAYvF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAClD;AAwBD,QAAA,MAAM,aAAa,GAAI,mBAAmB,kBAAkB,4CAiE3D,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -28,11 +28,11 @@ const BizThreadCard = ({ item, onClick }) => {
28
28
  const currentUserId = useAuthStore((state) => state.userID);
29
29
  const displayName = resolveBizDisplayName(item, t);
30
30
  const avatarUrl = resolveBizAvatarUrl(item);
31
- const badgeLabel = resolveBizBadgeLabel(item.chatCategory, t);
31
+ const badgeLabel = resolveBizBadgeLabel(item.peer.type, t);
32
32
  const latestMessagePreview = parseBizLatestMessage(item.latestMsg, currentUserId, tCommon, item.peer.fullName);
33
33
  const latestMessageTime = formatLatestMessageTime(item.latestMsgSendTime || null);
34
34
  const unreadCount = (_a = item.unreadCount) !== null && _a !== void 0 ? _a : 0;
35
- return (_jsxs("button", { type: "button", onClick: () => onClick(item), "data-testid": "biz-inbox-thread-card", className: "flex w-full shrink-0 items-start gap-2 border-b border-[#EFEFEF] bg-white p-3 text-left transition-colors hover:bg-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#1677ff]", children: [_jsx(BizThreadAvatar, { chatCategory: item.chatCategory, displayName: displayName, avatarUrl: avatarUrl, badgeLabel: badgeLabel }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("div", { className: "flex min-h-[25.6px] items-center justify-between gap-1", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BizThreadTitle, { chatCategory: item.chatCategory, displayName: displayName, hasUnread: unreadCount > 0 }) }), latestMessageTime && (_jsx("span", { className: "shrink-0 text-[12px] font-normal leading-[160%] text-[#747B7E] [font-feature-settings:'liga'_off,'clig'_off]", children: latestMessageTime }))] }), _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("p", { className: clsx("min-w-0 flex-1 truncate text-[14px] leading-[160%] [font-feature-settings:'liga'_off,'clig'_off]", unreadCount > 0
35
+ return (_jsxs("button", { type: "button", onClick: () => onClick(item), "data-testid": "biz-inbox-thread-card", className: "flex w-full shrink-0 items-start gap-2 border-b border-[#EFEFEF] bg-white p-3 text-left transition-colors hover:bg-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#1677ff]", children: [_jsx(BizThreadAvatar, { peerType: item.peer.type, chatCategory: item.chatCategory, displayName: displayName, avatarUrl: avatarUrl, badgeLabel: badgeLabel }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("div", { className: "flex min-h-[25.6px] items-center justify-between gap-1", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BizThreadTitle, { peerType: item.peer.type, chatCategory: item.chatCategory, displayName: displayName, hasUnread: unreadCount > 0 }) }), latestMessageTime && (_jsx("span", { className: "shrink-0 text-[12px] font-normal leading-[160%] text-[#747B7E] [font-feature-settings:'liga'_off,'clig'_off]", children: latestMessageTime }))] }), _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("p", { className: clsx("min-w-0 flex-1 truncate text-[14px] leading-[160%] [font-feature-settings:'liga'_off,'clig'_off]", unreadCount > 0
36
36
  ? "font-[510] text-black"
37
37
  : "font-normal tracking-[0.14px] text-[#5C6366]"), children: latestMessagePreview }), unreadCount > 0 && _jsx(UnreadBadge, { count: unreadCount })] })] })] }));
38
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"BizThreadList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadList.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAMvF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC1D;AAYD,QAAA,MAAM,aAAa,GAAI,oFAOpB,kBAAkB,4CAwGpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"BizThreadList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadList.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAOvF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC1D;AAYD,QAAA,MAAM,aAAa,GAAI,oFAOpB,kBAAkB,4CA8GpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -7,6 +7,7 @@ import InfiniteScroll from "react-infinite-scroll-component";
7
7
  import { DChatSDK } from "../../constants/sdk";
8
8
  import useBizConversationStore from "../../store/bizConversation";
9
9
  import useConversationStore from "../../store/conversation";
10
+ import { buildBizSdkConversation } from "../../utils/bizConversation";
10
11
  import { Icon } from "../../components/icon";
11
12
  import BizThreadCard from "./BizThreadCard";
12
13
  const FooterSkeleton = () => (_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("div", { className: "h-10 w-10 animate-pulse rounded-full bg-neutral-200" }), _jsxs("div", { className: "flex flex-1 flex-col gap-2", children: [_jsx("div", { className: "h-3 w-1/2 animate-pulse rounded bg-neutral-200" }), _jsx("div", { className: "h-2.5 w-1/3 animate-pulse rounded bg-neutral-200" })] })] }));
@@ -19,18 +20,22 @@ const BizThreadList = ({ items, isLoading, isFetchingNextPage, hasNextPage, onLo
19
20
  const selectConversation = useBizConversationStore((state) => state.selectConversation);
20
21
  const setConversationData = useConversationStore((state) => state.setConversationData);
21
22
  const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
22
- const syncSdkConversation = (conversationId) => {
23
+ const syncSdkConversation = (item) => {
24
+ const conversationId = item.conversationId;
25
+ setSelectedConversationId(conversationId);
23
26
  const cachedConversation = sdkConversations[conversationId];
24
27
  if (cachedConversation) {
25
28
  setConversationData(cachedConversation);
26
- setSelectedConversationId(conversationId);
27
- return;
29
+ }
30
+ else {
31
+ setConversationData(buildBizSdkConversation(item));
28
32
  }
29
33
  DChatSDK.getMultipleConversation([conversationId])
30
34
  .then((res) => {
31
- if (res.data.length > 0) {
35
+ if (res.data.length > 0 &&
36
+ useConversationStore.getState().selectedConversationId ===
37
+ conversationId) {
32
38
  setConversationData(res.data[0]);
33
- setSelectedConversationId(conversationId);
34
39
  }
35
40
  })
36
41
  .catch((error) => {
@@ -42,7 +47,7 @@ const BizThreadList = ({ items, isLoading, isFetchingNextPage, hasNextPage, onLo
42
47
  newSearchParams.set("threadId", item.conversationId);
43
48
  router.push(`${pathname}?${newSearchParams.toString()}`);
44
49
  selectConversation(item);
45
- syncSdkConversation(item.conversationId);
50
+ syncSdkConversation(item);
46
51
  onSelectThread === null || onSelectThread === void 0 ? void 0 : onSelectThread(item);
47
52
  };
48
53
  const handleEndReached = () => {
@@ -1,9 +1,10 @@
1
- import { BizChatCategory } from "../../types/biz";
1
+ import { BizChatCategory, BizPeerType } from "../../types/biz";
2
2
  export interface BizThreadTitleProps {
3
+ peerType: BizPeerType;
3
4
  chatCategory: BizChatCategory;
4
5
  displayName: string;
5
6
  hasUnread?: boolean;
6
7
  }
7
- declare const BizThreadTitle: ({ chatCategory, displayName, hasUnread, }: BizThreadTitleProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const BizThreadTitle: ({ peerType, chatCategory, displayName, hasUnread, }: BizThreadTitleProps) => import("react/jsx-runtime").JSX.Element;
8
9
  export default BizThreadTitle;
9
10
  //# sourceMappingURL=BizThreadTitle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BizThreadTitle.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadTitle.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,cAAc,GAAI,2CAIrB,mBAAmB,4CAwBrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"BizThreadTitle.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadTitle.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,cAAc,GAAI,qDAKrB,mBAAmB,4CA2BrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -2,6 +2,9 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import { Icon } from "../../components/icon";
5
- import { BizChatCategory } from "../../types/biz";
6
- const BizThreadTitle = ({ chatCategory, displayName, hasUnread = false, }) => (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [chatCategory === BizChatCategory.GROUP && (_jsx(Icon, { icon: "user-two-b", size: 12, className: "shrink-0 text-black" })), chatCategory === BizChatCategory.BIZ_BOT_PDP && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center gap-0.5 rounded-full border border-white bg-[linear-gradient(93deg,#607CFB_0%,#1B3FE4_100%)] px-1 py-0.5 text-white", children: _jsx(Icon, { icon: "shield-done-b", size: 8 }) })), chatCategory === BizChatCategory.BIZ_BOT_CRM && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-black text-white", children: _jsx(Icon, { icon: "droppii-o-1", size: 8 }) })), _jsx("span", { className: clsx("min-w-0 truncate text-[16px] leading-[160%] text-black [font-feature-settings:'liga'_off,'clig'_off]", hasUnread ? "font-bold tracking-[0.16px]" : "font-[510]"), children: displayName })] }));
5
+ import { BizChatCategory, BizPeerType } from "../../types/biz";
6
+ const BizThreadTitle = ({ peerType, chatCategory, displayName, hasUnread = false, }) => (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [(chatCategory === BizChatCategory.GROUP ||
7
+ peerType === BizPeerType.GROUP) && (_jsx(Icon, { icon: "user-two-b", size: 12, className: "shrink-0 text-black" })), peerType === BizPeerType.BOT &&
8
+ chatCategory === BizChatCategory.BIZ_BOT_PDP && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center gap-0.5 rounded-full border border-white bg-[linear-gradient(93deg,#607CFB_0%,#1B3FE4_100%)] px-1 py-0.5 text-white", children: _jsx(Icon, { icon: "shield-done-b", size: 8 }) })), peerType === BizPeerType.BOT &&
9
+ chatCategory === BizChatCategory.BIZ_BOT_CRM && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-black text-white", children: _jsx(Icon, { icon: "droppii-o-1", size: 8 }) })), _jsx("span", { className: clsx("min-w-0 truncate text-[16px] leading-[160%] text-black [font-feature-settings:'liga'_off,'clig'_off]", hasUnread ? "font-bold tracking-[0.16px]" : "font-[510]"), children: displayName })] }));
7
10
  export default BizThreadTitle;
@@ -1 +1 @@
1
- {"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"AAiBA,QAAA,MAAM,cAAc,+CA8EnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"AAgBA,QAAA,MAAM,cAAc,+CAwEnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -10,7 +10,6 @@ import { useMessageListScroll } from "../../hooks/message/useMessageListScroll";
10
10
  import useBizConversationStore from "../../store/bizConversation";
11
11
  import useConversationStore from "../../store/conversation";
12
12
  import useAuthStore from "../../store/auth";
13
- import { useIsSdkMessageReady } from "../../hooks/common/useIsSdkMessageReady";
14
13
  import { isBizGroupChat } from "../../utils/bizConversation";
15
14
  import emitter from "../../utils/events";
16
15
  import BizMessageItem from "./item/BizMessageItem";
@@ -18,15 +17,14 @@ const BizMessageList = () => {
18
17
  const { t } = useTranslation("biz-inbox");
19
18
  const { user } = useChatContext();
20
19
  const authUserID = useAuthStore((state) => state.userID);
21
- const isSdkReady = useIsSdkMessageReady();
22
20
  const conversation = useBizConversationStore((state) => state.conversationData);
23
21
  const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
24
22
  const conversationId = selectedConversationId || (conversation === null || conversation === void 0 ? void 0 : conversation.conversationId) || "";
25
23
  const isGroupChat = conversation ? isBizGroupChat(conversation) : false;
26
- const messageController = useMessage(conversationId, undefined, isSdkReady && !!conversationId);
24
+ const messageController = useMessage(conversationId);
27
25
  const { scrollRef, loadMoreOldMessage, handleInfiniteScroll, scrollToBottomIfAtBottom, } = useMessageListScroll(Object.assign({ conversationId, userId: (user === null || user === void 0 ? void 0 : user.userID) || authUserID }, messageController));
28
26
  const { loadState, moreOldLoading } = messageController;
29
- const isMessageLoading = !conversationId || !isSdkReady || loadState.initLoading;
27
+ const isMessageLoading = !conversationId || loadState.initLoading;
30
28
  useEffect(() => {
31
29
  emitter.on("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
32
30
  return () => {
@@ -1 +1 @@
1
- {"version":3,"file":"BizThreadDetailHeader.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizThreadDetailHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAqBD,QAAA,MAAM,qBAAqB,GAAI,2BAG5B,0BAA0B,4CA0C5B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"BizThreadDetailHeader.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizThreadDetailHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAqBD,QAAA,MAAM,qBAAqB,GAAI,2BAG5B,0BAA0B,4CA2C5B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -10,8 +10,8 @@ const BizThreadDetailHeader = ({ conversation, onBack, }) => {
10
10
  const { t } = useTranslation("biz-inbox");
11
11
  const displayName = resolveBizDisplayName(conversation, t);
12
12
  const avatarUrl = resolveBizAvatarUrl(conversation);
13
- const badgeLabel = resolveBizBadgeLabel(conversation.chatCategory, t);
13
+ const badgeLabel = resolveBizBadgeLabel(conversation.peer.type, t);
14
14
  const subtitle = t("thread_detail.profile_hint");
15
- return (_jsxs("div", { "data-testid": "biz-thread-detail-header", className: "flex w-full cursor-default items-center border-b border-[#EFEFEF] bg-white p-2 shadow-[inset_0px_-1px_0px_0px_rgba(61,63,64,0.1)]", children: [_jsx(HeaderIconButton, { icon: "arrow-left-o", onClick: onBack, testId: "biz-thread-detail-back" }), _jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 px-1", "data-testid": "biz-thread-detail-profile", children: [_jsx(BizThreadAvatar, { chatCategory: conversation.chatCategory, displayName: displayName, avatarUrl: avatarUrl, badgeLabel: badgeLabel }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx(BizThreadTitle, { chatCategory: conversation.chatCategory, displayName: displayName }), _jsx("p", { className: "truncate text-[10px] font-normal leading-[160%] tracking-[0.1px] text-[#5C6366] [font-feature-settings:'liga'_off,'clig'_off]", children: subtitle })] })] })] }));
15
+ return (_jsxs("div", { "data-testid": "biz-thread-detail-header", className: "flex w-full cursor-default items-center border-b border-[#EFEFEF] bg-white p-2 shadow-[inset_0px_-1px_0px_0px_rgba(61,63,64,0.1)]", children: [_jsx(HeaderIconButton, { icon: "arrow-left-o", onClick: onBack, testId: "biz-thread-detail-back" }), _jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 px-1", "data-testid": "biz-thread-detail-profile", children: [_jsx(BizThreadAvatar, { peerType: conversation.peer.type, chatCategory: conversation.chatCategory, displayName: displayName, avatarUrl: avatarUrl, badgeLabel: badgeLabel }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx(BizThreadTitle, { peerType: conversation.peer.type, chatCategory: conversation.chatCategory, displayName: displayName }), _jsx("p", { className: "truncate text-[10px] font-normal leading-[160%] tracking-[0.1px] text-[#5C6366] [font-feature-settings:'liga'_off,'clig'_off]", children: subtitle })] })] })] }));
16
16
  };
17
17
  export default BizThreadDetailHeader;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAStB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CAgGnE,CAAC"}
1
+ {"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAStB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CAqGnE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import "../styles/global.css";
4
- import { createContext, useContext, useEffect, useState } from "react";
4
+ import { createContext, useContext, useEffect, useRef, useState } from "react";
5
5
  import { ConnectStatus, SyncStatus, } from "../types/chat";
6
6
  import { DChatSDK } from "../constants/sdk";
7
7
  import MainLayout from "../layout";
@@ -12,7 +12,7 @@ const queryClient = new QueryClient();
12
12
  export const ChatContext = createContext({
13
13
  user: null,
14
14
  connectStatus: ConnectStatus.Disconnected,
15
- syncStatus: SyncStatus.Loading,
15
+ syncStatus: SyncStatus.Success,
16
16
  getSelfUserInfo: () => { },
17
17
  updateConnectStatus: () => { },
18
18
  updateSyncStatus: () => { },
@@ -20,9 +20,10 @@ export const ChatContext = createContext({
20
20
  export const useChatContext = () => useContext(ChatContext);
21
21
  export const ChatProvider = ({ children, config }) => {
22
22
  const [connectStatus, setConnectStatus] = useState(ConnectStatus.Disconnected);
23
- const [syncStatus, setSyncStatus] = useState(SyncStatus.Loading);
23
+ const [syncStatus, setSyncStatus] = useState(SyncStatus.Success);
24
24
  const [user, setUser] = useState(null);
25
25
  const initAuthStore = useAuthStore((state) => state.initAuthStore);
26
+ const lastUserIdRef = useRef();
26
27
  const setFallbackUserFromAuth = () => {
27
28
  const { userID } = useAuthStore.getState();
28
29
  if (!userID)
@@ -62,24 +63,27 @@ export const ChatProvider = ({ children, config }) => {
62
63
  setSyncStatus(status);
63
64
  };
64
65
  useEffect(() => {
65
- if (config) {
66
- initAuthStore({
67
- accessToken: config.accessToken,
68
- apiAddress: config.apiAddr,
69
- platformID: config.platformID,
70
- userID: config.userID,
71
- wsAddress: config.wsAddr,
72
- applicationType: config.applicationType,
73
- isCrm: config.isCrm,
74
- });
75
- setUser({
76
- userID: config.userID,
77
- nickname: "",
78
- faceURL: "",
79
- });
80
- setSyncStatus(SyncStatus.Loading);
66
+ if (!config)
67
+ return;
68
+ initAuthStore({
69
+ accessToken: config.accessToken,
70
+ apiAddress: config.apiAddr,
71
+ platformID: config.platformID,
72
+ userID: config.userID,
73
+ wsAddress: config.wsAddr,
74
+ applicationType: config.applicationType,
75
+ isCrm: config.isCrm,
76
+ });
77
+ setUser({
78
+ userID: config.userID,
79
+ nickname: "",
80
+ faceURL: "",
81
+ });
82
+ if (lastUserIdRef.current !== config.userID) {
83
+ lastUserIdRef.current = config.userID;
84
+ setConnectStatus(ConnectStatus.Disconnected);
81
85
  }
82
- }, [config]);
86
+ }, [config, initAuthStore]);
83
87
  return (_jsx(ChatContext.Provider, { value: {
84
88
  user,
85
89
  connectStatus,
@@ -1 +1 @@
1
- {"version":3,"file":"useBizActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBizActiveConversation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,eAAO,MAAM,wBAAwB,GACnC,mBAAmB,uBAAuB,EAAE,SAwE7C,CAAC"}
1
+ {"version":3,"file":"useBizActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBizActiveConversation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,eAAO,MAAM,wBAAwB,GACnC,mBAAmB,uBAAuB,EAAE,SA2E7C,CAAC"}
@@ -5,6 +5,7 @@ import { useChatContext } from "../../context/ChatContext";
5
5
  import { ConnectStatus } from "../../types/chat";
6
6
  import useBizConversationStore from "../../store/bizConversation";
7
7
  import useConversationStore from "../../store/conversation";
8
+ import { buildBizSdkConversation } from "../../utils/bizConversation";
8
9
  export const useBizActiveConversation = (conversationItems) => {
9
10
  const searchParams = useSearchParams();
10
11
  const threadId = searchParams.get("threadId");
@@ -22,23 +23,24 @@ export const useBizActiveConversation = (conversationItems) => {
22
23
  return;
23
24
  }
24
25
  setSelectedConversationId(threadId);
26
+ const matchedThread = conversationItems.find((item) => item.conversationId === threadId);
25
27
  const currentBizData = useBizConversationStore.getState().conversationData;
26
- if ((currentBizData === null || currentBizData === void 0 ? void 0 : currentBizData.conversationId) !== threadId) {
27
- const matchedThread = conversationItems.find((item) => item.conversationId === threadId);
28
- if (matchedThread) {
29
- selectConversation(matchedThread);
30
- }
28
+ if ((currentBizData === null || currentBizData === void 0 ? void 0 : currentBizData.conversationId) !== threadId && matchedThread) {
29
+ selectConversation(matchedThread);
31
30
  }
32
31
  if (connectStatus !== ConnectStatus.Connected)
33
32
  return;
34
33
  const cachedConversation = sdkConversations[threadId];
35
34
  if (cachedConversation) {
36
35
  setConversationData(cachedConversation);
37
- return;
36
+ }
37
+ else if (matchedThread) {
38
+ setConversationData(buildBizSdkConversation(matchedThread));
38
39
  }
39
40
  DChatSDK.getMultipleConversation([threadId])
40
41
  .then((res) => {
41
- if (res.data.length > 0) {
42
+ if (res.data.length > 0 &&
43
+ useConversationStore.getState().selectedConversationId === threadId) {
42
44
  setConversationData(res.data[0]);
43
45
  }
44
46
  })
@@ -1 +1 @@
1
- {"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,cAAc,YAoT1B,CAAC"}
1
+ {"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,cAAc,YAuT1B,CAAC"}
@@ -25,6 +25,7 @@ export const useGlobalEvent = () => {
25
25
  const { mutate: refetchChatToken } = useRefetchChatToken();
26
26
  const accessToken = useAuthStore((state) => state.accessToken);
27
27
  const chatToken = useAuthStore((state) => state.chatToken);
28
+ const userID = useAuthStore((state) => state.userID);
28
29
  const apiAddress = useAuthStore((state) => {
29
30
  return state.apiAddress;
30
31
  });
@@ -254,8 +255,9 @@ export const useGlobalEvent = () => {
254
255
  }
255
256
  }, [accessToken, apiAddress]);
256
257
  useEffect(() => {
257
- if (!!chatToken && apiAddress) {
258
- loginCheck();
258
+ if (!chatToken || !apiAddress || !userID) {
259
+ return;
259
260
  }
260
- }, [chatToken, apiAddress]);
261
+ loginCheck();
262
+ }, [chatToken, apiAddress, userID]);
261
263
  };
@@ -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;AAOjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc;;;;;qBAMO,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CA8PnC,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"}
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;;;;;qBAcO,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CA2QnC,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"}
@@ -5,6 +5,9 @@ import { PAGE_SIZE } from "../../constants";
5
5
  import { useLatest, useRequest } from "ahooks";
6
6
  import emitter, { emit } from "../../utils/events";
7
7
  import isEmpty from "lodash/isEmpty";
8
+ import { useChatContext } from "../../context/ChatContext";
9
+ import useAuthStore from "../../store/auth";
10
+ import { ConnectStatus } from "../../types/chat";
8
11
  export const visibleTypeMessage = [
9
12
  MessageType.TextMessage,
10
13
  MessageType.PictureMessage,
@@ -23,6 +26,12 @@ export const visibleTypeMessage = [
23
26
  MessageType.LogTextMessage,
24
27
  ];
25
28
  export const useMessage = (conversationId, searchClientMsgID, enabled = true) => {
29
+ const { connectStatus } = useChatContext();
30
+ const userID = useAuthStore((state) => state.userID);
31
+ const canLoad = enabled &&
32
+ connectStatus === ConnectStatus.Connected &&
33
+ !!conversationId &&
34
+ !!userID;
26
35
  const [loadState, setLoadState] = useState({
27
36
  initLoading: true,
28
37
  hasMoreOld: true,
@@ -30,7 +39,8 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
30
39
  messageList: [],
31
40
  });
32
41
  const latestLoadState = useLatest(loadState);
33
- const enabledRef = useLatest(enabled);
42
+ const canLoadRef = useLatest(canLoad);
43
+ const conversationIdRef = useLatest(conversationId);
34
44
  const { loading: moreOldLoading, runAsync: getMoreOldMessages } = useRequest(async (loadMore = true) => {
35
45
  var _a, _b, _c, _d, _e;
36
46
  const reqConversationID = conversationId;
@@ -42,41 +52,63 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
42
52
  conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
43
53
  viewType: ViewType.History,
44
54
  };
45
- const { data } = await DChatSDK.getAdvancedHistoryMessageList(params);
46
- if (conversationId !== reqConversationID)
47
- return;
48
- setTimeout(() => setLoadState((preState) => {
49
- let messageList = [
50
- ...(loadMore ? preState.messageList : []),
51
- ...data.messageList.toReversed(),
52
- ];
53
- messageList = removeDuplicateMessages(messageList);
54
- return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreOld: !data.isEnd, messageList });
55
- }));
55
+ try {
56
+ const { data } = await DChatSDK.getAdvancedHistoryMessageList(params);
57
+ if (conversationIdRef.current !== reqConversationID)
58
+ return;
59
+ setTimeout(() => {
60
+ if (conversationIdRef.current !== reqConversationID)
61
+ return;
62
+ setLoadState((preState) => {
63
+ let messageList = [
64
+ ...(loadMore ? preState.messageList : []),
65
+ ...data.messageList.toReversed(),
66
+ ];
67
+ messageList = removeDuplicateMessages(messageList);
68
+ return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreOld: !data.isEnd, messageList });
69
+ });
70
+ });
71
+ }
72
+ catch (_f) {
73
+ if (conversationIdRef.current !== reqConversationID)
74
+ return;
75
+ setLoadState((preState) => (Object.assign(Object.assign({}, preState), { initLoading: false })));
76
+ }
56
77
  }, {
57
78
  manual: true,
58
79
  });
59
80
  const { loading: moreNewLoading, runAsync: getMoreNewMessages } = useRequest(async (loadMore = true) => {
60
81
  var _a, _b;
61
82
  const reqConversationID = conversationId;
62
- const { data } = await DChatSDK.getAdvancedHistoryMessageListReverse({
63
- count: PAGE_SIZE.large,
64
- startClientMsgID: loadMore
65
- ? ((_b = (_a = latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList[0]) === null || _b === void 0 ? void 0 : _b.clientMsgID) || ""
66
- : "",
67
- conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
68
- viewType: ViewType.Search,
69
- });
70
- if (conversationId !== reqConversationID)
71
- return;
72
- setTimeout(() => setLoadState((preState) => {
73
- let messageList = [
74
- ...data.messageList.toReversed(),
75
- ...(loadMore ? preState.messageList : []),
76
- ];
77
- messageList = removeDuplicateMessages(messageList);
78
- return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreNew: !data.isEnd, messageList });
79
- }));
83
+ try {
84
+ const { data } = await DChatSDK.getAdvancedHistoryMessageListReverse({
85
+ count: PAGE_SIZE.large,
86
+ startClientMsgID: loadMore
87
+ ? ((_b = (_a = latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList[0]) === null || _b === void 0 ? void 0 : _b.clientMsgID) || ""
88
+ : "",
89
+ conversationID: conversationId !== null && conversationId !== void 0 ? conversationId : "",
90
+ viewType: ViewType.Search,
91
+ });
92
+ if (conversationIdRef.current !== reqConversationID)
93
+ return;
94
+ setTimeout(() => {
95
+ if (conversationIdRef.current !== reqConversationID)
96
+ return;
97
+ setLoadState((preState) => {
98
+ let messageList = [
99
+ ...data.messageList.toReversed(),
100
+ ...(loadMore ? preState.messageList : []),
101
+ ];
102
+ messageList = removeDuplicateMessages(messageList);
103
+ return Object.assign(Object.assign({}, preState), { initLoading: false, hasMoreNew: !data.isEnd, messageList });
104
+ });
105
+ });
106
+ }
107
+ catch (_c) {
108
+ if (conversationIdRef.current !== reqConversationID)
109
+ return;
110
+ setLoadState((preState) => (Object.assign(Object.assign({}, preState), { initLoading: false })));
111
+ }
80
112
  }, {
81
113
  manual: true,
82
114
  });
@@ -127,7 +159,7 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
127
159
  useEffect(() => {
128
160
  const pushNewMessage = (message) => {
129
161
  var _a, _b;
130
- if (!enabledRef.current)
162
+ if (!canLoadRef.current)
131
163
  return;
132
164
  if ((_b = (_a = latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList) === null || _b === void 0 ? void 0 : _b.find((item) => item.clientMsgID === message.clientMsgID)) {
133
165
  return;
@@ -138,7 +170,7 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
138
170
  });
139
171
  };
140
172
  const updateOneMessage = (message) => {
141
- if (!enabledRef.current)
173
+ if (!canLoadRef.current)
142
174
  return;
143
175
  setLoadState((preState) => {
144
176
  var _a, _b, _c, _d;
@@ -167,7 +199,7 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
167
199
  });
168
200
  };
169
201
  const removeOneMessage = (clientMsgID) => {
170
- if (!enabledRef.current)
202
+ if (!canLoadRef.current)
171
203
  return;
172
204
  setLoadState((preState) => (Object.assign(Object.assign({}, preState), { messageList: preState.messageList.filter((msg) => msg.clientMsgID !== clientMsgID) })));
173
205
  };
@@ -181,7 +213,7 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
181
213
  };
182
214
  }, []);
183
215
  useEffect(() => {
184
- if (!enabled) {
216
+ if (!canLoad) {
185
217
  setLoadState({
186
218
  initLoading: true,
187
219
  hasMoreOld: true,
@@ -206,7 +238,7 @@ export const useMessage = (conversationId, searchClientMsgID, enabled = true) =>
206
238
  messageList: [],
207
239
  }));
208
240
  };
209
- }, [conversationId, searchClientMsgID, enabled]);
241
+ }, [conversationId, searchClientMsgID, canLoad, userID]);
210
242
  return {
211
243
  loadState,
212
244
  latestLoadState,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/desk-message/index.tsx"],"names":[],"mappings":"AAWA,UAAU,qBAAqB;IAC7B,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,QAAA,MAAM,gBAAgB,GAAI,2BAA2B,qBAAqB,4CA+BzE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/desk-message/index.tsx"],"names":[],"mappings":"AAWA,UAAU,qBAAqB;IAC7B,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,QAAA,MAAM,gBAAgB,GAAI,2BAA2B,qBAAqB,4CA6BzE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -4,14 +4,14 @@ import MessageList from "../../components/message/MessageList";
4
4
  import DeskConversationList from "../../components/conversation/DeskConversationList";
5
5
  import { useChatContext } from "../../context/ChatContext";
6
6
  import { Spin } from "antd";
7
- import { ConnectStatus, SyncStatus } from "../../types/chat";
7
+ import { ConnectStatus } from "../../types/chat";
8
8
  import useConversationStore from "../../store/conversation";
9
9
  import DeskAssignedSession from "../../components/session/DeskAssignedSession";
10
10
  import ThreadInfo from "../../components/thread/ThreadInfo";
11
11
  const DChatDeskMessage = ({ openCreateCannedModal }) => {
12
12
  const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
13
13
  const searchClientMsgID = useConversationStore((state) => state.searchClientMsgID);
14
- const { connectStatus, syncStatus } = useChatContext();
15
- return (_jsx(_Fragment, { children: connectStatus === ConnectStatus.Connected ? (_jsx(Spin, { spinning: syncStatus === SyncStatus.Loading, children: _jsxs("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: [_jsx(DeskAssignedSession, {}), _jsx(DeskConversationList, {}), _jsx(MessageList, { conversationId: selectedConversationId, searchClientMsgID: searchClientMsgID, openCreateCannedModal: openCreateCannedModal }), _jsx(ThreadInfo, {})] }) })) : (_jsx("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: connectStatus === ConnectStatus.Connecting && _jsx(Spin, { fullscreen: true }) })) }));
14
+ const { connectStatus } = useChatContext();
15
+ return (_jsx(_Fragment, { children: connectStatus === ConnectStatus.Connected ? (_jsxs("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: [_jsx(DeskAssignedSession, {}), _jsx(DeskConversationList, {}), _jsx(MessageList, { conversationId: selectedConversationId, searchClientMsgID: searchClientMsgID, openCreateCannedModal: openCreateCannedModal }), _jsx(ThreadInfo, {})] })) : (_jsx("div", { className: "flex flex-1 flex-row h-screen bg-gray-50", children: connectStatus === ConnectStatus.Connecting && _jsx(Spin, { fullscreen: true }) })) }));
16
16
  };
17
17
  export default DChatDeskMessage;