@droppii-org/chat-sdk 0.6.18 → 0.6.19

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,SAkG1C,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,SAqF1C,CAAC"}
@@ -3,24 +3,12 @@ import { useEffect, useRef } 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.
14
6
  const searchParams = useSearchParams();
15
7
  const searchParamsSnapshot = searchParams.toString();
16
8
  const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
17
9
  const setConversationData = useConversationStore((state) => state.setConversationData);
18
10
  const clearSelectedConversation = useConversationStore((state) => state.clearSelectedConversation);
19
11
  const setSearchClientMsgID = useConversationStore((state) => state.setSearchClientMsgID);
20
- // Which ?messageId deep link has already been pushed into the store, keyed
21
- // by thread. Without it, the effect's re-runs (conversationItems changes on
22
- // every list mutation) would keep re-applying the URL's message and yank the
23
- // user back there after they jumped somewhere else in the same thread.
24
12
  const appliedMessageTargetRef = useRef(null);
25
13
  useEffect(() => {
26
14
  var _a;
@@ -29,18 +17,15 @@ export const useActiveConversation = (conversationItems) => {
29
17
  : null;
30
18
  const threadId = (_a = params === null || params === void 0 ? void 0 : params.get("threadId")) !== null && _a !== void 0 ? _a : null;
31
19
  if (!threadId) {
20
+ const hasPendingTarget = !!((params === null || params === void 0 ? void 0 : params.get("userId")) ||
21
+ (params === null || params === void 0 ? void 0 : params.get("groupId")) ||
22
+ (params === null || params === void 0 ? void 0 : params.get("botId")));
23
+ if (hasPendingTarget)
24
+ return;
32
25
  appliedMessageTargetRef.current = null;
33
26
  clearSelectedConversation();
34
27
  return;
35
28
  }
36
- // conversationItems changes identity on every list mutation (a message
37
- // send fires 2+ WS events — optimistic + ack), re-running this effect
38
- // even though the active thread hasn't changed. setSelectedConversationId
39
- // resets quotedMessage unconditionally on every call, which cascades into
40
- // useMessage/usePinnedMessages re-fetching and ahooks' useRequest
41
- // cancelling+re-running its in-flight request (surfaces as an uncaught
42
- // CancelledError). Guard against re-selecting the same thread, matching
43
- // the identity check setConversationData already uses below.
44
29
  if (useConversationStore.getState().selectedConversationId !== threadId) {
45
30
  setSelectedConversationId(threadId);
46
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droppii-org/chat-sdk",
3
- "version": "0.6.18",
3
+ "version": "0.6.19",
4
4
  "description": "Droppii React Chat SDK",
5
5
  "repository": {
6
6
  "type": "git",
@@ -85,7 +85,7 @@
85
85
  "dependencies": {
86
86
  "@ant-design/cssinjs": "^1.24.0",
87
87
  "@ant-design/icons": "^6.0.0",
88
- "@droppii-org/wasm-client-sdk": "0.5.0",
88
+ "@droppii-org/wasm-client-sdk": "0.5.1",
89
89
  "@lexical/code": "^0.34.0",
90
90
  "@lexical/html": "^0.34.0",
91
91
  "@lexical/link": "^0.34.0",