@droppii-org/chat-sdk 0.5.2 → 0.5.3

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":"useActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useActiveConversation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,qBAAqB,GAChC,mBAAmB,oBAAoB,EAAE,SAuC1C,CAAC"}
1
+ {"version":3,"file":"useActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useActiveConversation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,qBAAqB,GAChC,mBAAmB,oBAAoB,EAAE,SAoD1C,CAAC"}
@@ -3,12 +3,23 @@ import { useEffect } from "react";
3
3
  import { useSearchParams } from "next/navigation";
4
4
  import useConversationStore from "../../store/conversation";
5
5
  export const useActiveConversation = (conversationItems) => {
6
+ // Only used as an effect trigger on navigation — Next's Pages Router
7
+ // compat shim for useSearchParams isn't a live subscription, so its
8
+ // snapshot can still be one render behind a just-completed router.push
9
+ // when this effect re-fires for an unrelated reason (e.g. conversationItems
10
+ // changing after an async group-info fetch). Re-reading window.location
11
+ // directly below (instead of trusting this snapshot's value) avoids ever
12
+ // acting on that staleness — see the "URL clobbered right after selecting
13
+ // a group" regression this guards.
6
14
  const searchParams = useSearchParams();
7
- const threadId = searchParams.get("threadId");
15
+ const searchParamsSnapshot = searchParams.toString();
8
16
  const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
9
17
  const setConversationData = useConversationStore((state) => state.setConversationData);
10
18
  const clearSelectedConversation = useConversationStore((state) => state.clearSelectedConversation);
11
19
  useEffect(() => {
20
+ const threadId = typeof window !== "undefined"
21
+ ? new URLSearchParams(window.location.search).get("threadId")
22
+ : null;
12
23
  if (!threadId) {
13
24
  clearSelectedConversation();
14
25
  return;
@@ -22,8 +33,8 @@ export const useActiveConversation = (conversationItems) => {
22
33
  setConversationData(matchedThread);
23
34
  }
24
35
  }, [
25
- threadId,
26
36
  conversationItems,
37
+ searchParamsSnapshot,
27
38
  setSelectedConversationId,
28
39
  setConversationData,
29
40
  clearSelectedConversation,
@@ -4,11 +4,7 @@ export interface DChatConversationInboxProps {
4
4
  onSelectThread?: (conversation: ConversationListItem) => void;
5
5
  className?: string;
6
6
  moreOptions?: MoreOptionConfig[];
7
- /**
8
- * Scopes the conversation list to a single BE chat category (e.g. Mall
9
- * buyer inbox = Droppii Support + linked sellers only). Omit to keep the
10
- * existing unscoped behavior (all categories for the application type).
11
- */
7
+ /** Scopes the conversation list to a single BE chat category. Omit for unscoped behavior. */
12
8
  chatCategory?: ChatCategory;
13
9
  /** Passed through to ConversationInboxHeader — see its own prop docs. */
14
10
  showSearch?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-inbox/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,MAAM,WAAW,2BAA2B;IAC1C,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACnC;AAED,QAAA,MAAM,sBAAsB,GAAI,qGAQ7B,2BAA2B,4CA8E7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-inbox/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,MAAM,WAAW,2BAA2B;IAC1C,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACjC,6FAA6F;IAC7F,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACnC;AAED,QAAA,MAAM,sBAAsB,GAAI,qGAQ7B,2BAA2B,4CA2F7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -6,6 +6,7 @@ import { Empty } from "antd";
6
6
  import { useBoolean } from "ahooks";
7
7
  import clsx from "clsx";
8
8
  import useAuthStore from "../../store/auth";
9
+ import useConversationStore from "../../store/conversation";
9
10
  import { useConversationList } from "../../hooks/conversation/useConversationList";
10
11
  import { useActiveConversation } from "../../hooks/conversation/useActiveConversation";
11
12
  import { ConversationInboxHeader } from "../../components/conversation-inbox";
@@ -23,6 +24,7 @@ const DChatConversationInbox = ({ onSelectThread, className, moreOptions, chatCa
23
24
  const groupId = (_b = searchParams.get("groupId")) !== null && _b !== void 0 ? _b : undefined;
24
25
  const botId = (_c = searchParams.get("botId")) !== null && _c !== void 0 ? _c : undefined;
25
26
  const applicationType = useAuthStore((state) => state.applicationType);
27
+ const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
26
28
  const [isSearchOpen, { setTrue: openSearch, setFalse: closeSearch }] = useBoolean(false);
27
29
  const isApplicationTypeValid = Object.values(DChatApplicationType).includes(applicationType);
28
30
  const conversationList = useConversationList({
@@ -33,7 +35,15 @@ const DChatConversationInbox = ({ onSelectThread, className, moreOptions, chatCa
33
35
  // Any of the four targets opens the detail screen — useResolveConversation
34
36
  // turns userId/groupId/botId into a thread (creating the bot one when
35
37
  // missing), so entry points that only know the peer still work.
36
- const hasConversationTarget = !!(threadId || userId || groupId || botId);
38
+ // threadId alone must also match selectedConversationId: clearSelectedConversation
39
+ // strips threadId from the URL via history.replaceState, which Next's Pages
40
+ // Router compat shim for useSearchParams doesn't react to (only router.push/
41
+ // replace do) — without this check, a stale threadId here would keep
42
+ // rendering the detail screen against an already-cleared store forever.
43
+ const hasConversationTarget = !!((threadId && threadId === selectedConversationId) ||
44
+ userId ||
45
+ groupId ||
46
+ botId);
37
47
  if (hasConversationTarget) {
38
48
  return (_jsx(DChatConversationDetail, { className: className, moreOptions: moreOptions, conversationId: threadId !== null && threadId !== void 0 ? threadId : undefined, userId: userId, groupId: groupId, botId: botId }));
39
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droppii-org/chat-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Droppii React Chat SDK",
5
5
  "repository": {
6
6
  "type": "git",