@droppii-org/chat-sdk 0.0.26 → 0.0.27

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,7 +1,5 @@
1
- import { SessionType } from "@openim/wasm-client-sdk";
2
1
  interface DChatBubbleProps {
3
- sourceID: string;
4
- sessionType: SessionType;
2
+ conversationID: string;
5
3
  className?: string;
6
4
  }
7
5
  declare const DChatBubble: (props: DChatBubbleProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/chatBubble/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQtD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,mDAsB3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/chatBubble/index.tsx"],"names":[],"mappings":"AAQA,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,mDAkC3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -2,26 +2,32 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import ChatBubble from "../../components/chatBubble/ChatBubble";
3
3
  import { useChatContext } from "../../context/ChatContext";
4
4
  import { ConnectStatus } from "../../types/chat";
5
- import { useConversationDetail } from "../../hooks/conversation/useConversation";
5
+ import { useConversationList } from "../../hooks/conversation/useConversation";
6
6
  import useConversationStore from "../../hooks/conversation/useConversationStore";
7
7
  import { useEffect } from "react";
8
+ import { SessionType } from "@openim/wasm-client-sdk";
8
9
  const DChatBubble = (props) => {
9
- const { sourceID, sessionType, className } = props;
10
+ const { conversationID, className } = props;
10
11
  const { connectStatus } = useChatContext();
11
- const { conversationDetail } = useConversationDetail({
12
- sourceID,
13
- sessionType,
14
- });
12
+ if (connectStatus !== ConnectStatus.Connected)
13
+ return null;
14
+ const { conversationList } = useConversationList();
15
15
  const setSelectedThreadId = useConversationStore((state) => state.setSelectedThreadId);
16
16
  const setConversationData = useConversationStore((state) => state.setConversationData);
17
+ const setSelectedSourceId = useConversationStore((state) => state.setSelectedSourceId);
17
18
  useEffect(() => {
18
- if (!conversationDetail)
19
+ if (!conversationList)
19
20
  return;
20
- setSelectedThreadId(conversationDetail.conversationID);
21
- setConversationData(conversationDetail);
22
- }, [conversationDetail]);
23
- if (connectStatus !== ConnectStatus.Connected)
24
- return null;
21
+ const conversation = conversationList.find((item) => item.conversationID === conversationID);
22
+ if (!conversation)
23
+ return;
24
+ const sourceId = (conversation === null || conversation === void 0 ? void 0 : conversation.conversationType) === SessionType.Group
25
+ ? conversation === null || conversation === void 0 ? void 0 : conversation.groupID
26
+ : conversation === null || conversation === void 0 ? void 0 : conversation.userID;
27
+ setSelectedThreadId(conversation.conversationID);
28
+ setConversationData(conversation);
29
+ setSelectedSourceId(sourceId);
30
+ }, [conversationList, conversationID]);
25
31
  return _jsx(ChatBubble, { className: className });
26
32
  };
27
33
  export default DChatBubble;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droppii-org/chat-sdk",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "Droppii React Chat SDK",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",