@droppii-org/chat-sdk 0.6.47 → 0.6.49

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PinnedMessagesPanel.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/PinnedMessagesPanel.tsx"],"names":[],"mappings":"AAYA,UAAU,wBAAwB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,mBAAmB,GAAI,8BAI1B,wBAAwB,4CAqG1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"PinnedMessagesPanel.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/PinnedMessagesPanel.tsx"],"names":[],"mappings":"AAYA,UAAU,wBAAwB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,mBAAmB,GAAI,8BAI1B,wBAAwB,4CAmH1B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -17,6 +17,17 @@ const PinnedMessagesPanel = ({ open, onClose, canUnpin = true, }) => {
17
17
  const conversationId = selectedConversationId || (conversation === null || conversation === void 0 ? void 0 : conversation.conversationID) || "";
18
18
  const { unpinMessage } = usePinMessage();
19
19
  const [openContextMenuId, setOpenContextMenuId] = useState(null);
20
+ // forceRender keeps the drawer mounted (rc-drawer then skips destroyOnHidden),
21
+ // so each opening keys a fresh list and "Xem thêm" expansions start collapsed.
22
+ const [openCount, setOpenCount] = useState(open ? 1 : 0);
23
+ const [wasOpen, setWasOpen] = useState(open);
24
+ if (open !== wasOpen) {
25
+ setWasOpen(open);
26
+ if (open) {
27
+ setOpenCount((count) => count + 1);
28
+ setOpenContextMenuId(null);
29
+ }
30
+ }
20
31
  useEffect(() => {
21
32
  if (open && pinnedMessageList.length === 0) {
22
33
  onClose();
@@ -46,6 +57,6 @@ const PinnedMessagesPanel = ({ open, onClose, canUnpin = true, }) => {
46
57
  borderTopRightRadius: 16,
47
58
  overflow: "hidden",
48
59
  },
49
- }, getContainer: false, forceRender: true, children: _jsxs("div", { className: "flex h-full flex-col bg-white", children: [_jsxs("div", { className: "flex items-center gap-4 border-b border-gray-25 px-3 py-4", children: [_jsx("span", { className: "flex-1 text-lg font-bold text-gray-900", children: t("pinned_panel_title") }), _jsx(Button, { type: "text", shape: "default", className: "h-6 w-6 p-0 text-gray-900", onClick: onClose, "aria-label": t("pinned_panel_title"), children: _jsx(Icon, { icon: "close-b", size: 24 }) })] }), _jsxs("div", { className: "flex flex-1 flex-col gap-3 overflow-y-auto py-3", children: [_jsx("p", { className: "px-3 text-sm leading-[160%] text-gray-600", children: t("pinned_panel_hint") }), pinnedMessageList.map((message) => (_jsx(PinnedMessageItem, { message: message, contextMenuOpen: openContextMenuId === message.clientMsgID, onContextMenuOpenChange: (isOpen) => setOpenContextMenuId(isOpen ? message.clientMsgID : null), onUnpin: handleUnpin, onJump: handleJump, canUnpin: canUnpin }, message.clientMsgID)))] })] }) }));
60
+ }, getContainer: false, forceRender: true, children: _jsxs("div", { className: "flex h-full flex-col bg-white", children: [_jsxs("div", { className: "flex items-center gap-4 border-b border-gray-25 px-3 py-4", children: [_jsx("span", { className: "flex-1 text-lg font-bold text-gray-900", children: t("pinned_panel_title") }), _jsx(Button, { type: "text", shape: "default", className: "h-6 w-6 p-0 text-gray-900", onClick: onClose, "aria-label": t("pinned_panel_title"), children: _jsx(Icon, { icon: "close-b", size: 24 }) })] }), _jsxs("div", { className: "flex flex-1 flex-col gap-3 overflow-y-auto py-3", children: [_jsx("p", { className: "px-3 text-sm leading-[160%] text-gray-600", children: t("pinned_panel_hint") }), pinnedMessageList.map((message) => (_jsx(PinnedMessageItem, { message: message, contextMenuOpen: openContextMenuId === message.clientMsgID, onContextMenuOpenChange: (isOpen) => setOpenContextMenuId(isOpen ? message.clientMsgID : null), onUnpin: handleUnpin, onJump: handleJump, canUnpin: canUnpin }, message.clientMsgID)))] }, openCount)] }) }));
50
61
  };
51
62
  export default PinnedMessagesPanel;
@@ -1 +1 @@
1
- {"version":3,"file":"CollapsibleText.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/CollapsibleText.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAiCrC,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAID,QAAA,MAAM,eAAe,GAAI,cAAc,oBAAoB,4CAwE1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"CollapsibleText.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/CollapsibleText.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAMf,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAiCrC,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAID,QAAA,MAAM,eAAe,GAAI,cAAc,oBAAoB,4CA0E1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -80,6 +80,6 @@ const CollapsibleText = ({ children }) => {
80
80
  topBeforeExpandRef.current =
81
81
  (_b = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().top) !== null && _b !== void 0 ? _b : null;
82
82
  setExpanded(true);
83
- }, className: clsx("pointer-events-auto absolute bottom-0 right-0 whitespace-nowrap rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--dc-color-link)]", MESSAGE_TEXT_CLASS), children: [_jsx("span", { "aria-hidden": true, children: "\u2026 " }), _jsx("span", { className: "text-[var(--dc-color-link)]", children: t("see_more") })] }))] }));
83
+ }, className: clsx("pointer-events-auto absolute bottom-0 right-0 whitespace-nowrap rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--dc-color-link)]", MESSAGE_TEXT_CLASS), children: [_jsx("span", { "aria-hidden": true, children: "\u2026 " }), _jsx("span", { className: "font-medium text-[var(--dc-color-link)]", children: t("see_more") })] }))] }));
84
84
  };
85
85
  export default CollapsibleText;
@@ -1 +1 @@
1
- {"version":3,"file":"useUnreadMessageIndicator.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useUnreadMessageIndicator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAUhE,eAAO,MAAM,8BAA8B,OAAO,CAAC;AA4DnD,UAAU,+BAA+B;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,WAAW,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,qDAIvC,+BAA+B;;;;;;CA4FjC,CAAC"}
1
+ {"version":3,"file":"useUnreadMessageIndicator.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useUnreadMessageIndicator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAUhE,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAoEnD,UAAU,+BAA+B;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,WAAW,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,qDAIvC,+BAA+B;;;;;;CA8FjC,CAAC"}
@@ -32,6 +32,12 @@ async function settleWithinTimeout(request, fallback) {
32
32
  clearTimeout(timer);
33
33
  }
34
34
  }
35
+ // A viewer outside the conversation (an agent browsing a shared support thread)
36
+ // has no local copy, so mark-as-read fails and the server keeps it all unread.
37
+ const hasLocalConversation = (conversationId) => settleWithinTimeout(async () => {
38
+ const { data } = await DChatSDK.getMultipleConversation([conversationId]);
39
+ return !!(data === null || data === void 0 ? void 0 : data.some((item) => item.conversationID === conversationId));
40
+ }, false);
35
41
  const fetchFirstUnreadMessage = (conversationId) => settleWithinTimeout(async () => {
36
42
  var _a;
37
43
  const { data } = await DChatSDK.getFirstUnreadMessage(conversationId);
@@ -93,7 +99,9 @@ export const useUnreadMessageIndicator = ({ conversationId = "", searchClientMsg
93
99
  const targetPromise = openTargetClientMsgID
94
100
  ? fetchMessage(conversationId, openTargetClientMsgID)
95
101
  : Promise.resolve(undefined);
96
- const firstUnreadMessage = await fetchFirstUnreadMessage(conversationId);
102
+ const firstUnreadMessage = (await hasLocalConversation(conversationId))
103
+ ? await fetchFirstUnreadMessage(conversationId)
104
+ : null;
97
105
  const openTarget = await targetPromise;
98
106
  if (requestId !== requestIdRef.current)
99
107
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droppii-org/chat-sdk",
3
- "version": "0.6.47",
3
+ "version": "0.6.49",
4
4
  "description": "Droppii React Chat SDK",
5
5
  "repository": {
6
6
  "type": "git",