@droppii-org/chat-sdk 0.6.6 → 0.6.7
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.
- package/dist/hooks/conversation/useConversationList.d.ts.map +1 -1
- package/dist/hooks/conversation/useConversationList.js +23 -4
- package/dist/screens/conversation-detail/index.d.ts.map +1 -1
- package/dist/screens/conversation-detail/index.js +3 -2
- package/dist/store/conversation.d.ts.map +1 -1
- package/dist/store/conversation.js +7 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversationList.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversationList.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAI/E,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,UAAU,yBAAyB;IACjC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AASD,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB,KAChC,
|
|
1
|
+
{"version":3,"file":"useConversationList.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversationList.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAI/E,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,UAAU,yBAAyB;IACjC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AASD,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB,KAChC,yBA8FF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { CbEvents } from "@droppii-org/wasm-client-sdk";
|
|
4
4
|
import { DChatSDK } from "../../constants/sdk";
|
|
5
5
|
import { useChatContext } from "../../context/ChatContext";
|
|
@@ -21,16 +21,29 @@ export const useConversationList = (params) => {
|
|
|
21
21
|
isApplicationTypeValid &&
|
|
22
22
|
connectStatus === ConnectStatus.Connected;
|
|
23
23
|
const appParams = useMemo(() => ({ applicationType, chatCategory }), [applicationType, chatCategory]);
|
|
24
|
+
// Guards against loadInitial overlapping itself — e.g. OnSyncServerFinish
|
|
25
|
+
// firing again (common right after connect, while WASM is still catching
|
|
26
|
+
// up) before the previous fetch has resolved, which would otherwise fire
|
|
27
|
+
// a second concurrent getConversationListByReq call.
|
|
28
|
+
const isLoadingInitialRef = useRef(false);
|
|
24
29
|
const loadInitial = useCallback(async () => {
|
|
30
|
+
if (isLoadingInitialRef.current)
|
|
31
|
+
return;
|
|
32
|
+
isLoadingInitialRef.current = true;
|
|
25
33
|
setIsLoading(true);
|
|
26
34
|
try {
|
|
27
35
|
const hasMore = await getConversationListByReq(false, appParams);
|
|
28
36
|
setHasNextPage(hasMore);
|
|
29
37
|
}
|
|
30
38
|
finally {
|
|
39
|
+
isLoadingInitialRef.current = false;
|
|
31
40
|
setIsLoading(false);
|
|
32
41
|
}
|
|
33
42
|
}, [getConversationListByReq, appParams]);
|
|
43
|
+
// Always points at the latest loadInitial (fresh appParams) without being
|
|
44
|
+
// an effect dependency itself — see the effect below.
|
|
45
|
+
const loadInitialRef = useRef(loadInitial);
|
|
46
|
+
loadInitialRef.current = loadInitial;
|
|
34
47
|
const fetchNextPage = useCallback(() => {
|
|
35
48
|
if (!hasNextPage || isFetchingNextPage)
|
|
36
49
|
return;
|
|
@@ -39,18 +52,24 @@ export const useConversationList = (params) => {
|
|
|
39
52
|
.then((hasMore) => setHasNextPage(hasMore))
|
|
40
53
|
.finally(() => setIsFetchingNextPage(false));
|
|
41
54
|
}, [hasNextPage, isFetchingNextPage, getConversationListByReq, appParams]);
|
|
55
|
+
// Deliberately keyed on queryEnabled alone (not loadInitial/appParams) —
|
|
56
|
+
// a parent re-render passing a new chatCategory reference (or any other
|
|
57
|
+
// appParams change) shouldn't tear down and resubscribe this listener,
|
|
58
|
+
// which would otherwise also refire the initial fetch for no real reason.
|
|
59
|
+
// onSyncFinish still calls the CURRENT loadInitial via the ref above, so
|
|
60
|
+
// a genuine appParams change is still picked up by the next sync event.
|
|
42
61
|
useEffect(() => {
|
|
43
62
|
if (!queryEnabled)
|
|
44
63
|
return;
|
|
45
|
-
void
|
|
64
|
+
void loadInitialRef.current();
|
|
46
65
|
const onSyncFinish = () => {
|
|
47
|
-
void
|
|
66
|
+
void loadInitialRef.current();
|
|
48
67
|
};
|
|
49
68
|
DChatSDK.on(CbEvents.OnSyncServerFinish, onSyncFinish);
|
|
50
69
|
return () => {
|
|
51
70
|
DChatSDK.off(CbEvents.OnSyncServerFinish, onSyncFinish);
|
|
52
71
|
};
|
|
53
|
-
}, [queryEnabled
|
|
72
|
+
}, [queryEnabled]);
|
|
54
73
|
const items = useMemo(() => conversationList.map(toConversationListItem), [conversationList]);
|
|
55
74
|
return {
|
|
56
75
|
items,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-detail/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation-detail/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAWrF,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAGrD,MAAM,WAAW,4BACf,SAAQ,4BAA4B,EACpC,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,uBAAuB,GAAI,wFAS9B,4BAA4B,mDAoN9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
-
import { jsx as _jsx,
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import { useState } from "react";
|
|
15
15
|
import { useTranslation } from "react-i18next";
|
|
16
16
|
import { useChatContext } from "../../context/ChatContext";
|
|
@@ -18,6 +18,7 @@ import { useChatNavigate } from "../../hooks/conversation/useChatNavigate";
|
|
|
18
18
|
import { useBoolean } from "ahooks";
|
|
19
19
|
import clsx from "clsx";
|
|
20
20
|
import { Empty, Spin } from "antd";
|
|
21
|
+
import { Icon } from "../../components/icon";
|
|
21
22
|
import useConversationStore from "../../store/conversation";
|
|
22
23
|
import ThreadProfilePanel from "../../components/conversation-detail/ThreadProfilePanel";
|
|
23
24
|
import MediaResourcePanel from "../../components/media-resources/MediaResourcePanel";
|
|
@@ -82,7 +83,7 @@ const DChatConversationDetail = (_a) => {
|
|
|
82
83
|
return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-white", children: _jsx(Spin, {}) }));
|
|
83
84
|
}
|
|
84
85
|
if (error) {
|
|
85
|
-
return (
|
|
86
|
+
return (_jsxs("div", { "data-testid": "conversation-detail-root", className: clsx("relative flex h-full w-full flex-col overflow-hidden bg-white", className), children: [_jsx("div", { "data-testid": "conversation-detail-header", className: "flex w-full shrink-0 cursor-default items-center border-b border-gray-25 bg-white p-2 shadow-inset-gray-divider", children: _jsx("button", { type: "button", onClick: handleBack, "data-testid": "conversation-detail-back", "data-cp-name": "HeaderIconButton", className: "flex shrink-0 cursor-pointer items-center justify-center p-2 text-[var(--dc-color-primary)]", children: _jsx(Icon, { icon: "arrow-left-o", size: 24 }) }) }), _jsx("div", { className: "flex flex-1 items-center justify-center", children: _jsx(Empty, { description: t("thread_detail.resolve_failed") }) })] }));
|
|
86
87
|
}
|
|
87
88
|
if (!conversation) {
|
|
88
89
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/store/conversation.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAY3C,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,SAElD,CAAC;AAEF,QAAA,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/store/conversation.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAY3C,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,SAElD,CAAC;AAEF,QAAA,MAAM,oBAAoB,gFAkYvB,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
|
|
@@ -143,16 +143,17 @@ const useConversationStore = create((set, get) => ({
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
// Derives view-only/block state from fetch/cache above for fresh
|
|
146
|
-
// loads and external entries. Unconfirmed (support/bot) threads
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
|
|
146
|
+
// loads and external entries. Unconfirmed (support/bot) threads skip
|
|
147
|
+
// this membership check entirely — BE already gates access to them
|
|
148
|
+
// (a non-member's device never syncs the conversation at all), so
|
|
149
|
+
// there's no "removed from group" state to detect for this kind.
|
|
150
|
+
if (groupID && isConfirmedGroup) {
|
|
150
151
|
const notAMember = !get().currentMemberInGroup.has(groupID);
|
|
151
152
|
const isPublic = ((_a = get().currentGroupInfo.get(groupID)) === null || _a === void 0 ? void 0 : _a.visibility) === GroupVisibility.Public;
|
|
152
|
-
if (notAMember &&
|
|
153
|
+
if (notAMember && isPublic) {
|
|
153
154
|
set({ isViewOnlyMember: true });
|
|
154
155
|
}
|
|
155
|
-
else if (
|
|
156
|
+
else if (notAMember) {
|
|
156
157
|
// Blocked: don't fall through to setting currentConversation below
|
|
157
158
|
// — that would re-open the very conversation just cleared.
|
|
158
159
|
get().clearSelectedConversation();
|