@droppii-org/chat-sdk 0.0.30 → 0.0.31
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/assets/conversationBg.png +0 -0
- package/dist/assets/images/conversationBg.png +0 -0
- package/dist/assets/images/imageFailed.png +0 -0
- package/dist/assets/sdk/sql-wasm.wasm +0 -0
- package/dist/assets/sdk/version +1 -0
- package/dist/assets/sdk/wasm_exec.js +575 -0
- package/dist/assets/svg/document.d.ts +2 -0
- package/dist/assets/svg/document.d.ts.map +1 -0
- package/dist/assets/svg/document.js +2 -0
- package/dist/assets/svg/document.tsx +37 -0
- package/dist/assets/svg/index.d.ts +2 -0
- package/dist/assets/svg/index.d.ts.map +1 -0
- package/dist/assets/svg/index.js +1 -0
- package/dist/assets/svg/index.ts +1 -0
- package/dist/components/chatBubble/ChatBubble.d.ts.map +1 -1
- package/dist/components/chatBubble/ChatBubble.js +6 -11
- package/dist/components/conversation/ConversationItemList.d.ts +7 -0
- package/dist/components/conversation/ConversationItemList.d.ts.map +1 -0
- package/dist/components/conversation/ConversationItemList.js +20 -0
- package/dist/components/conversation/DeskConversationList.d.ts +1 -5
- package/dist/components/conversation/DeskConversationList.d.ts.map +1 -1
- package/dist/components/conversation/DeskConversationList.js +40 -24
- package/dist/components/mediaCollection/FileCollection.d.ts +3 -0
- package/dist/components/mediaCollection/FileCollection.d.ts.map +1 -0
- package/dist/components/mediaCollection/FileCollection.js +54 -0
- package/dist/components/mediaCollection/ImageCollection.d.ts +3 -0
- package/dist/components/mediaCollection/ImageCollection.d.ts.map +1 -0
- package/dist/components/mediaCollection/ImageCollection.js +37 -0
- package/dist/components/mediaCollection/LinkCollection.d.ts +3 -0
- package/dist/components/mediaCollection/LinkCollection.d.ts.map +1 -0
- package/dist/components/mediaCollection/LinkCollection.js +8 -0
- package/dist/components/mediaCollection/VideoCollection.d.ts +3 -0
- package/dist/components/mediaCollection/VideoCollection.d.ts.map +1 -0
- package/dist/components/mediaCollection/VideoCollection.js +53 -0
- package/dist/components/mediaCollection/index.d.ts +9 -0
- package/dist/components/mediaCollection/index.d.ts.map +1 -0
- package/dist/components/mediaCollection/index.js +54 -0
- package/dist/components/message/MessageHeader.d.ts.map +1 -1
- package/dist/components/message/MessageHeader.js +2 -1
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +14 -2
- package/dist/components/message/footer/FilePreview.d.ts +0 -1
- package/dist/components/message/footer/FilePreview.d.ts.map +1 -1
- package/dist/components/message/footer/FilePreview.js +4 -4
- package/dist/components/message/footer/ToolbarPlugin.js +1 -1
- package/dist/components/message/footer/index.js +1 -1
- package/dist/components/message/item/FileMessage.d.ts.map +1 -1
- package/dist/components/message/item/FileMessage.js +2 -1
- package/dist/components/message/item/ImageMessage.js +3 -3
- package/dist/components/message/item/TextMessage.js +2 -2
- package/dist/components/message/item/index.js +1 -1
- package/dist/components/session/AssignedSessionFilter.js +9 -10
- package/dist/constants/images.d.ts +5 -0
- package/dist/constants/images.d.ts.map +1 -0
- package/dist/constants/images.js +7 -0
- package/dist/context/ChatContext.d.ts +2 -1
- package/dist/context/ChatContext.d.ts.map +1 -1
- package/dist/context/ChatContext.js +17 -24
- package/dist/hooks/collection/useMediaCollection.d.ts +229 -0
- package/dist/hooks/collection/useMediaCollection.d.ts.map +1 -0
- package/dist/hooks/collection/useMediaCollection.js +66 -0
- package/dist/hooks/common/useIsMobile.d.ts +2 -0
- package/dist/hooks/common/useIsMobile.d.ts.map +1 -0
- package/dist/hooks/common/useIsMobile.js +15 -0
- package/dist/hooks/conversation/useConversationStore.d.ts +3 -2
- package/dist/hooks/conversation/useConversationStore.d.ts.map +1 -1
- package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
- package/dist/hooks/global/useGlobalEvent.js +55 -6
- package/dist/hooks/init/useChatToken.d.ts +2 -0
- package/dist/hooks/init/useChatToken.d.ts.map +1 -0
- package/dist/hooks/init/useChatToken.js +11 -0
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +31 -12
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +2 -5
- package/dist/locales/i18n.d.ts +3 -0
- package/dist/locales/i18n.d.ts.map +1 -0
- package/dist/locales/i18n.js +16 -0
- package/dist/locales/i18n.ts +18 -0
- package/dist/locales/vi/common.json +9 -0
- package/dist/screens/chatBubble/index.d.ts.map +1 -1
- package/dist/screens/chatBubble/index.js +4 -3
- package/dist/screens/deskMessage/index.d.ts.map +1 -1
- package/dist/screens/deskMessage/index.js +3 -3
- package/dist/services/api.d.ts +2 -0
- package/dist/services/api.d.ts.map +1 -0
- package/dist/services/api.js +16 -0
- package/dist/services/query.d.ts +5 -0
- package/dist/services/query.d.ts.map +1 -0
- package/dist/services/query.js +4 -0
- package/dist/services/routes.d.ts +15 -0
- package/dist/services/routes.d.ts.map +1 -0
- package/dist/services/routes.js +14 -0
- package/dist/store/auth.d.ts +4 -0
- package/dist/store/auth.d.ts.map +1 -0
- package/dist/store/auth.js +16 -0
- package/dist/styles/global.css +1 -1
- package/dist/types/chat.d.ts +10 -4
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/dto.d.ts +35 -0
- package/dist/types/dto.d.ts.map +1 -0
- package/dist/types/dto.js +1 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/common.js +12 -0
- package/dist/utils/imCommon.d.ts +0 -1
- package/dist/utils/imCommon.d.ts.map +1 -1
- package/dist/utils/imCommon.js +0 -5
- package/package.json +15 -3
- package/dist/assets/openIM.wasm +0 -0
- package/dist/components/ChatBubble.d.ts +0 -10
- package/dist/components/ChatBubble.d.ts.map +0 -1
- package/dist/components/ChatBubble.js +0 -28
- package/dist/components/message/MessageItem.d.ts +0 -7
- package/dist/components/message/MessageItem.d.ts.map +0 -1
- package/dist/components/message/MessageItem.js +0 -21
- package/dist/components/message/footer/BottomSection.d.ts +0 -3
- package/dist/components/message/footer/BottomSection.d.ts.map +0 -1
- package/dist/components/message/footer/BottomSection.js +0 -6
- package/dist/screens/desk-message/index.d.ts +0 -3
- package/dist/screens/desk-message/index.d.ts.map +0 -1
- package/dist/screens/desk-message/index.js +0 -15
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/sdk.d.ts +0 -1
- package/dist/types/sdk.d.ts.map +0 -1
- package/dist/types/sdk.js +0 -1
|
@@ -156,7 +156,7 @@ export const ToolbarPlugin = () => {
|
|
|
156
156
|
removeSelectionListener();
|
|
157
157
|
};
|
|
158
158
|
}, [editor]);
|
|
159
|
-
return (_jsxs("div", { className: "flex items-center gap-2 px-4", children: [formatTextButtons.map((button) => {
|
|
159
|
+
return (_jsxs("div", { className: "flex items-center gap-2 px-4 pt-1", children: [formatTextButtons.map((button) => {
|
|
160
160
|
const { icon, onPress, key, isActive } = button;
|
|
161
161
|
return (_jsx(Button, { type: "text", shape: "default", className: getButtonClasses(isActive), onClick: onPress, children: icon }, key));
|
|
162
162
|
}), insertListButtons.map((button) => {
|
|
@@ -60,6 +60,6 @@ const MessageFooterProvider = (props) => {
|
|
|
60
60
|
}
|
|
61
61
|
setListUploadFiles([]);
|
|
62
62
|
}, [sendMergeMessage, sendTextMessage, listUploadFiles]);
|
|
63
|
-
return (_jsx(MessageFooterContext.Provider, { value: { onSendMessage, listUploadFiles, setListUploadFiles }, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsxs("div", { className: "border-t pb-2 flex flex-col gap-1", children: [listUploadFiles.length > 0 && _jsx(FilePreview, {}), _jsx(ToolbarPlugin, {}), _jsx("div", { className: "relative px-4", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "border border-indigo-500 rounded-md bg-blue-100 min-h-[64px] max-h-[140px] overflow-y-auto px-3 py-2 text-sm" }), ErrorBoundary: LexicalErrorBoundary, "aria-placeholder": "Nh\u1EADp tin nh\u1EAFn", placeholder: _jsx("div", { className: "absolute top-2 left-7 pointer-events-none", children: _jsx("p", { className: "text-gray-500 text-sm", children: "Nh\u1EADp tin nh\u1EAFn" }) }) }) }), _jsx(ActionBar, {})] }), _jsx(LinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(EnterHandler, {})] }) }));
|
|
63
|
+
return (_jsx(MessageFooterContext.Provider, { value: { onSendMessage, listUploadFiles, setListUploadFiles }, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsxs("div", { className: "border-t pb-2 flex flex-col gap-1 bg-white", children: [listUploadFiles.length > 0 && _jsx(FilePreview, {}), _jsx(ToolbarPlugin, {}), _jsx("div", { className: "relative px-4", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "border border-indigo-500 rounded-md bg-blue-100 min-h-[64px] max-h-[140px] overflow-y-auto px-3 py-2 text-sm" }), ErrorBoundary: LexicalErrorBoundary, "aria-placeholder": "Nh\u1EADp tin nh\u1EAFn", placeholder: _jsx("div", { className: "absolute top-2 left-7 pointer-events-none", children: _jsx("p", { className: "text-gray-500 text-sm", children: "Nh\u1EADp tin nh\u1EAFn" }) }) }) }), _jsx(ActionBar, {})] }), _jsx(LinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(EnterHandler, {})] }) }));
|
|
64
64
|
};
|
|
65
65
|
export default MessageFooterProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/FileMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/FileMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,UAAU,qBAAqB;IAC7B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,qBAAqB,4CAmCpD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { shortenFileName } from "../footer/FilePreview";
|
|
3
|
+
import { documentIcon } from "../../../assets/svg";
|
|
3
4
|
const FileMessageItem = (props) => {
|
|
4
5
|
var _a;
|
|
5
6
|
const { message } = props;
|
|
@@ -3,7 +3,7 @@ import { MessageStatus } from "@openim/wasm-client-sdk";
|
|
|
3
3
|
import { Image, Spin } from "antd";
|
|
4
4
|
const min = (a, b) => (a > b ? b : a);
|
|
5
5
|
const ImageMessageItem = (props) => {
|
|
6
|
-
var _a, _b, _c;
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
7
|
const { message } = props;
|
|
8
8
|
const imageHeight = message.pictureElem.sourcePicture.height;
|
|
9
9
|
const imageWidth = message.pictureElem.sourcePicture.width;
|
|
@@ -11,8 +11,8 @@ const ImageMessageItem = (props) => {
|
|
|
11
11
|
const minHeight = min(200, imageWidth) * (imageHeight / imageWidth) + 2;
|
|
12
12
|
const adaptedHight = min(minHeight, snapshotMaxHeight) + 10;
|
|
13
13
|
const adaptedWidth = min(imageWidth, 200) + 10;
|
|
14
|
-
const sourceUrl = ((_c = message.pictureElem.
|
|
15
|
-
message.pictureElem.
|
|
14
|
+
const sourceUrl = ((_c = message.pictureElem.sourcePicture) === null || _c === void 0 ? void 0 : _c.url) ||
|
|
15
|
+
((_d = message.pictureElem.snapshotPicture) === null || _d === void 0 ? void 0 : _d.url);
|
|
16
16
|
const isSending = message.status === MessageStatus.Sending;
|
|
17
17
|
const minStyle = {
|
|
18
18
|
minHeight: `${adaptedHight}px`,
|
|
@@ -14,8 +14,8 @@ const TextMessageItem = (props) => {
|
|
|
14
14
|
if (Object.keys(extendMessageInfo).length > 0 &&
|
|
15
15
|
(extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.messageInfo)) {
|
|
16
16
|
const htmlContent = ((_b = (_a = extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.messageInfo) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content) || "";
|
|
17
|
-
return (_jsx("div", { className: "text-sm sm:text-base break-words whitespace-pre-line flex-1", dangerouslySetInnerHTML: { __html: htmlContent } }));
|
|
17
|
+
return (_jsx("div", { className: "!text-sm sm:text-base break-words whitespace-pre-line flex-1", dangerouslySetInnerHTML: { __html: htmlContent } }));
|
|
18
18
|
}
|
|
19
|
-
return (_jsx("span", { className: "text-sm sm:text-base whitespace-pre-wrap", children: ((_c = message === null || message === void 0 ? void 0 : message.textElem) === null || _c === void 0 ? void 0 : _c.content) || "" }));
|
|
19
|
+
return (_jsx("span", { className: "!text-sm sm:text-base whitespace-pre-wrap", children: ((_c = message === null || message === void 0 ? void 0 : message.textElem) === null || _c === void 0 ? void 0 : _c.content) || "" }));
|
|
20
20
|
};
|
|
21
21
|
export default TextMessageItem;
|
|
@@ -52,7 +52,7 @@ const MessageItem = ({ groupMessage }) => {
|
|
|
52
52
|
const isMine = (message === null || message === void 0 ? void 0 : message.sendID) === (user === null || user === void 0 ? void 0 : user.userID);
|
|
53
53
|
const showAvatar = messageIndex === messagesInGroup.length - 1;
|
|
54
54
|
const showSenderName = messageIndex === 0 && (message === null || message === void 0 ? void 0 : message.sessionType) === SessionType.Group;
|
|
55
|
-
return (_jsx("div", { className: clsx("flex", isMine ? "justify-end" : "justify-start"), children: _jsxs("div", { className: clsx("flex flex-1 items-end gap-2", isMine ? "justify-end" : "justify-start"), children: [!isMine && (_jsx("div", { className: "flex items-center justify-center w-[32px] h-[32px]", children: showAvatar && (_jsx(Avatar, { children: ((_b = (_a = message === null || message === void 0 ? void 0 : message.senderNickname) === null || _a === void 0 ? void 0 : _a.charAt) === null || _b === void 0 ? void 0 : _b.call(_a, 0)) || "A" })) })), _jsxs("div", { className: clsx("flex flex-col flex-[0.8]", isMine ? "items-end" : "items-start"), children: [!isMine && showSenderName && (_jsx("span", { className: "text-xs text-gray-500 mb-1 px-3", children: message === null || message === void 0 ? void 0 : message.senderNickname })), _jsxs("div", { className: clsx("px-3 py-2 rounded-2xl max-w-full break-words flex flex-col flex-1 text-gray-900 gap-1", isMine ? "bg-blue-100" : "bg-
|
|
55
|
+
return (_jsx("div", { className: clsx("flex", isMine ? "justify-end" : "justify-start"), children: _jsxs("div", { className: clsx("flex flex-1 items-end gap-2", isMine ? "justify-end" : "justify-start"), children: [!isMine && (_jsx("div", { className: "flex items-center justify-center w-[32px] h-[32px]", children: showAvatar && (_jsx(Avatar, { children: ((_b = (_a = message === null || message === void 0 ? void 0 : message.senderNickname) === null || _a === void 0 ? void 0 : _a.charAt) === null || _b === void 0 ? void 0 : _b.call(_a, 0)) || "A" })) })), _jsxs("div", { className: clsx("flex flex-col flex-[0.8]", isMine ? "items-end" : "items-start"), children: [!isMine && showSenderName && (_jsx("span", { className: "text-xs text-gray-500 mb-1 px-3", children: message === null || message === void 0 ? void 0 : message.senderNickname })), _jsxs("div", { className: clsx("px-3 py-2 rounded-2xl max-w-full break-words flex flex-col flex-1 text-gray-900 gap-1", isMine ? "bg-blue-100" : "bg-white"), children: [(message === null || message === void 0 ? void 0 : message.contentType) === MessageType.MergeMessage ? (_jsxs("div", { children: [(_d = (_c = message === null || message === void 0 ? void 0 : message.mergeElem) === null || _c === void 0 ? void 0 : _c.multiMessage) === null || _d === void 0 ? void 0 : _d.map((item) => {
|
|
56
56
|
return renderMessageByType(item);
|
|
57
57
|
}), (message === null || message === void 0 ? void 0 : message.textElem) && (_jsx(TextMessageItem, { message: message }))] })) : (renderMessageByType(message)), _jsx("span", { className: clsx("text-xs text-gray-500 text-right text-gray-500"), children: dayjs(message === null || message === void 0 ? void 0 : message.sendTime).format("HH:mm") })] })] })] }) }, message === null || message === void 0 ? void 0 : message.clientMsgID));
|
|
58
58
|
})] }, groupMessage === null || groupMessage === void 0 ? void 0 : groupMessage.groupMessageID));
|
|
@@ -7,7 +7,6 @@ import { SESSION_STATUS_ENUM, TAG_ENUM } from "../../constants";
|
|
|
7
7
|
const AssignedSessionFilter = ({ onFilterChange, className = "", }) => {
|
|
8
8
|
const [expandedCategories, setExpandedCategories] = useState(new Set([0]));
|
|
9
9
|
const [selectedFilter, setSelectedFilter] = useState(SESSION_STATUS_ENUM.UNASSIGNED);
|
|
10
|
-
console.log({ selectedFilter });
|
|
11
10
|
const summary = useConversationStore((state) => state.summary);
|
|
12
11
|
const setFilterSummary = useConversationStore((state) => state.setFilterSummary);
|
|
13
12
|
const messageCategories = useMemo(() => {
|
|
@@ -115,15 +114,15 @@ const AssignedSessionFilter = ({ onFilterChange, className = "", }) => {
|
|
|
115
114
|
}
|
|
116
115
|
setExpandedCategories(newExpanded);
|
|
117
116
|
};
|
|
118
|
-
const handleFilterSelect = (
|
|
119
|
-
const
|
|
120
|
-
setSelectedFilter(
|
|
121
|
-
// Find the selected category and subcategory
|
|
122
|
-
const category = messageCategories.find((cat) => cat.
|
|
117
|
+
const handleFilterSelect = (categoryKey, subCategoryKey) => {
|
|
118
|
+
const filterKey = subCategoryKey || categoryKey;
|
|
119
|
+
setSelectedFilter(filterKey);
|
|
120
|
+
// Find the selected category and subcategory by key
|
|
121
|
+
const category = messageCategories.find((cat) => cat.key === categoryKey);
|
|
123
122
|
let query;
|
|
124
123
|
if (category) {
|
|
125
|
-
if (
|
|
126
|
-
const subCategory = category.subCategories.find((sub) => sub.
|
|
124
|
+
if (subCategoryKey && category.subCategories) {
|
|
125
|
+
const subCategory = category.subCategories.find((sub) => sub.key === subCategoryKey);
|
|
127
126
|
query = subCategory === null || subCategory === void 0 ? void 0 : subCategory.query;
|
|
128
127
|
}
|
|
129
128
|
else {
|
|
@@ -133,14 +132,14 @@ const AssignedSessionFilter = ({ onFilterChange, className = "", }) => {
|
|
|
133
132
|
if (query) {
|
|
134
133
|
setFilterSummary(query);
|
|
135
134
|
}
|
|
136
|
-
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(
|
|
135
|
+
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(categoryKey, subCategoryKey);
|
|
137
136
|
};
|
|
138
137
|
return (_jsxs("div", { className: `w-64 bg-white border-r border-gray-200 flex flex-col ${className}`, children: [_jsx("div", { className: "p-4 border-b border-gray-200", children: _jsx("h2", { className: "text-lg font-semibold text-gray-800", children: "TIN NH\u1EAEN C\u1EE6A T\u00D4I" }) }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("ul", { className: "py-2", children: messageCategories.map((category, index) => (_jsxs("li", { children: [_jsxs("button", { onClick: () => {
|
|
139
138
|
if (category.subCategories) {
|
|
140
139
|
toggleCategory(index);
|
|
141
140
|
}
|
|
142
141
|
else {
|
|
143
|
-
handleFilterSelect(category.
|
|
142
|
+
handleFilterSelect(category.key);
|
|
144
143
|
}
|
|
145
144
|
}, className: `w-full flex items-center justify-between px-4 py-3 hover:bg-gray-50 transition-colors group ${selectedFilter === category.key && !category.subCategories
|
|
146
145
|
? "bg-blue-50 border-r-2 border-blue-500"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/constants/images.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM;;;CAGlB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import "../styles/global.css";
|
|
1
2
|
import { ChatContextType, ChatProviderProps } from "../types/chat";
|
|
2
3
|
export declare const ChatContext: import("react").Context<ChatContextType>;
|
|
3
4
|
export declare const useChatContext: () => ChatContextType;
|
|
4
|
-
export declare const ChatProvider: ({ children, config
|
|
5
|
+
export declare const ChatProvider: ({ children, config }: ChatProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
//# sourceMappingURL=ChatContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AAQvB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CAsDnE,CAAC"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import "../styles/global.css";
|
|
3
4
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
4
5
|
import { ConnectStatus, SyncStatus, } from "../types/chat";
|
|
5
6
|
import { DChatSDK } from "../constants/sdk";
|
|
6
7
|
import MainLayout from "../layout";
|
|
8
|
+
import useAuthStore from "../store/auth";
|
|
9
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
10
|
+
const queryClient = new QueryClient();
|
|
7
11
|
export const ChatContext = createContext({
|
|
8
12
|
user: null,
|
|
9
13
|
connectStatus: ConnectStatus.Disconnected,
|
|
10
14
|
syncStatus: SyncStatus.Success,
|
|
11
|
-
|
|
15
|
+
getSelfUserInfo: () => { },
|
|
12
16
|
updateConnectStatus: () => { },
|
|
13
17
|
updateSyncStatus: () => { },
|
|
14
18
|
});
|
|
15
19
|
export const useChatContext = () => useContext(ChatContext);
|
|
16
|
-
export const ChatProvider = ({ children, config
|
|
20
|
+
export const ChatProvider = ({ children, config }) => {
|
|
17
21
|
const [connectStatus, setConnectStatus] = useState(ConnectStatus.Disconnected);
|
|
18
22
|
const [syncStatus, setSyncStatus] = useState(SyncStatus.Success);
|
|
19
23
|
const [user, setUser] = useState(null);
|
|
20
|
-
const
|
|
24
|
+
const initAuthStore = useAuthStore((state) => state.initAuthStore);
|
|
25
|
+
const getSelfUserInfo = () => {
|
|
21
26
|
DChatSDK.getSelfUserInfo()
|
|
22
27
|
.then(({ data }) => {
|
|
23
28
|
setUser(data);
|
|
@@ -26,24 +31,6 @@ export const ChatProvider = ({ children, config, refetchToken, }) => {
|
|
|
26
31
|
console.error("getSelfUserInfo", errCode, errMsg);
|
|
27
32
|
});
|
|
28
33
|
};
|
|
29
|
-
const handleLogin = (newToken) => {
|
|
30
|
-
if (config) {
|
|
31
|
-
DChatSDK.login(Object.assign(Object.assign({}, config), { token: newToken || config.token }))
|
|
32
|
-
.then((res) => {
|
|
33
|
-
getUserInfo();
|
|
34
|
-
})
|
|
35
|
-
.catch(({ errCode, errMsg }) => {
|
|
36
|
-
console.error("handleLogin", errCode, errMsg);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const userTokenHandler = () => {
|
|
41
|
-
refetchToken().then((token) => {
|
|
42
|
-
if (!!token) {
|
|
43
|
-
handleLogin(token);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
34
|
const updateConnectStatus = (status) => {
|
|
48
35
|
setConnectStatus(status);
|
|
49
36
|
};
|
|
@@ -52,15 +39,21 @@ export const ChatProvider = ({ children, config, refetchToken, }) => {
|
|
|
52
39
|
};
|
|
53
40
|
useEffect(() => {
|
|
54
41
|
if (config) {
|
|
55
|
-
|
|
42
|
+
initAuthStore({
|
|
43
|
+
accessToken: config.accessToken,
|
|
44
|
+
apiAddress: config.apiAddr,
|
|
45
|
+
platformID: config.platformID,
|
|
46
|
+
userID: config.userID,
|
|
47
|
+
wsAddress: config.wsAddr,
|
|
48
|
+
});
|
|
56
49
|
}
|
|
57
50
|
}, [config]);
|
|
58
51
|
return (_jsx(ChatContext.Provider, { value: {
|
|
59
52
|
user,
|
|
60
53
|
connectStatus,
|
|
61
54
|
syncStatus,
|
|
62
|
-
|
|
55
|
+
getSelfUserInfo,
|
|
63
56
|
updateConnectStatus,
|
|
64
57
|
updateSyncStatus,
|
|
65
|
-
}, children: _jsx(MainLayout, { children: children }) }));
|
|
58
|
+
}, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(MainLayout, { children: children }) }) }));
|
|
66
59
|
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { MessageType } from "@openim/wasm-client-sdk";
|
|
2
|
+
import { MediaCollectionItem, MediaCollectionResponse } from "../../types/dto";
|
|
3
|
+
export declare const useMediaCollection: ({ recvID, contentType, }: {
|
|
4
|
+
recvID: string;
|
|
5
|
+
contentType: MessageType;
|
|
6
|
+
}) => {
|
|
7
|
+
error: Error;
|
|
8
|
+
isError: true;
|
|
9
|
+
isPending: false;
|
|
10
|
+
isLoadingError: false;
|
|
11
|
+
isRefetchError: true;
|
|
12
|
+
isSuccess: false;
|
|
13
|
+
isPlaceholderData: false;
|
|
14
|
+
status: "error";
|
|
15
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
16
|
+
hasPreviousPage: boolean;
|
|
17
|
+
isFetchNextPageError: boolean;
|
|
18
|
+
isFetchPreviousPageError: boolean;
|
|
19
|
+
isFetchingPreviousPage: boolean;
|
|
20
|
+
dataUpdatedAt: number;
|
|
21
|
+
errorUpdatedAt: number;
|
|
22
|
+
failureCount: number;
|
|
23
|
+
failureReason: Error | null;
|
|
24
|
+
errorUpdateCount: number;
|
|
25
|
+
isFetched: boolean;
|
|
26
|
+
isFetchedAfterMount: boolean;
|
|
27
|
+
isFetching: boolean;
|
|
28
|
+
isInitialLoading: boolean;
|
|
29
|
+
isPaused: boolean;
|
|
30
|
+
isRefetching: boolean;
|
|
31
|
+
isStale: boolean;
|
|
32
|
+
isEnabled: boolean;
|
|
33
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
34
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
35
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>>;
|
|
36
|
+
data: import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown> | undefined;
|
|
37
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
38
|
+
hasNextPage: boolean;
|
|
39
|
+
isFetchingNextPage: boolean;
|
|
40
|
+
isLoading: boolean;
|
|
41
|
+
groupedData: Record<string, MediaCollectionItem[]>;
|
|
42
|
+
dataFlatten: MediaCollectionItem[];
|
|
43
|
+
} | {
|
|
44
|
+
error: null;
|
|
45
|
+
isError: false;
|
|
46
|
+
isPending: false;
|
|
47
|
+
isLoadingError: false;
|
|
48
|
+
isRefetchError: false;
|
|
49
|
+
isFetchNextPageError: false;
|
|
50
|
+
isFetchPreviousPageError: false;
|
|
51
|
+
isSuccess: true;
|
|
52
|
+
isPlaceholderData: false;
|
|
53
|
+
status: "success";
|
|
54
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
55
|
+
hasPreviousPage: boolean;
|
|
56
|
+
isFetchingPreviousPage: boolean;
|
|
57
|
+
dataUpdatedAt: number;
|
|
58
|
+
errorUpdatedAt: number;
|
|
59
|
+
failureCount: number;
|
|
60
|
+
failureReason: Error | null;
|
|
61
|
+
errorUpdateCount: number;
|
|
62
|
+
isFetched: boolean;
|
|
63
|
+
isFetchedAfterMount: boolean;
|
|
64
|
+
isFetching: boolean;
|
|
65
|
+
isInitialLoading: boolean;
|
|
66
|
+
isPaused: boolean;
|
|
67
|
+
isRefetching: boolean;
|
|
68
|
+
isStale: boolean;
|
|
69
|
+
isEnabled: boolean;
|
|
70
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
71
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
72
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>>;
|
|
73
|
+
data: import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown> | undefined;
|
|
74
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
75
|
+
hasNextPage: boolean;
|
|
76
|
+
isFetchingNextPage: boolean;
|
|
77
|
+
isLoading: boolean;
|
|
78
|
+
groupedData: Record<string, MediaCollectionItem[]>;
|
|
79
|
+
dataFlatten: MediaCollectionItem[];
|
|
80
|
+
} | {
|
|
81
|
+
error: Error;
|
|
82
|
+
isError: true;
|
|
83
|
+
isPending: false;
|
|
84
|
+
isLoadingError: true;
|
|
85
|
+
isRefetchError: false;
|
|
86
|
+
isFetchNextPageError: false;
|
|
87
|
+
isFetchPreviousPageError: false;
|
|
88
|
+
isSuccess: false;
|
|
89
|
+
isPlaceholderData: false;
|
|
90
|
+
status: "error";
|
|
91
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
92
|
+
hasPreviousPage: boolean;
|
|
93
|
+
isFetchingPreviousPage: boolean;
|
|
94
|
+
dataUpdatedAt: number;
|
|
95
|
+
errorUpdatedAt: number;
|
|
96
|
+
failureCount: number;
|
|
97
|
+
failureReason: Error | null;
|
|
98
|
+
errorUpdateCount: number;
|
|
99
|
+
isFetched: boolean;
|
|
100
|
+
isFetchedAfterMount: boolean;
|
|
101
|
+
isFetching: boolean;
|
|
102
|
+
isInitialLoading: boolean;
|
|
103
|
+
isPaused: boolean;
|
|
104
|
+
isRefetching: boolean;
|
|
105
|
+
isStale: boolean;
|
|
106
|
+
isEnabled: boolean;
|
|
107
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
108
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
109
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>>;
|
|
110
|
+
data: import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown> | undefined;
|
|
111
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
112
|
+
hasNextPage: boolean;
|
|
113
|
+
isFetchingNextPage: boolean;
|
|
114
|
+
isLoading: boolean;
|
|
115
|
+
groupedData: Record<string, MediaCollectionItem[]>;
|
|
116
|
+
dataFlatten: MediaCollectionItem[];
|
|
117
|
+
} | {
|
|
118
|
+
error: null;
|
|
119
|
+
isError: false;
|
|
120
|
+
isPending: true;
|
|
121
|
+
isLoadingError: false;
|
|
122
|
+
isRefetchError: false;
|
|
123
|
+
isFetchNextPageError: false;
|
|
124
|
+
isFetchPreviousPageError: false;
|
|
125
|
+
isSuccess: false;
|
|
126
|
+
isPlaceholderData: false;
|
|
127
|
+
status: "pending";
|
|
128
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
129
|
+
hasPreviousPage: boolean;
|
|
130
|
+
isFetchingPreviousPage: boolean;
|
|
131
|
+
dataUpdatedAt: number;
|
|
132
|
+
errorUpdatedAt: number;
|
|
133
|
+
failureCount: number;
|
|
134
|
+
failureReason: Error | null;
|
|
135
|
+
errorUpdateCount: number;
|
|
136
|
+
isFetched: boolean;
|
|
137
|
+
isFetchedAfterMount: boolean;
|
|
138
|
+
isFetching: boolean;
|
|
139
|
+
isInitialLoading: boolean;
|
|
140
|
+
isPaused: boolean;
|
|
141
|
+
isRefetching: boolean;
|
|
142
|
+
isStale: boolean;
|
|
143
|
+
isEnabled: boolean;
|
|
144
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
145
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
146
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>>;
|
|
147
|
+
data: import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown> | undefined;
|
|
148
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
149
|
+
hasNextPage: boolean;
|
|
150
|
+
isFetchingNextPage: boolean;
|
|
151
|
+
isLoading: boolean;
|
|
152
|
+
groupedData: Record<string, MediaCollectionItem[]>;
|
|
153
|
+
dataFlatten: MediaCollectionItem[];
|
|
154
|
+
} | {
|
|
155
|
+
error: null;
|
|
156
|
+
isError: false;
|
|
157
|
+
isPending: true;
|
|
158
|
+
isLoadingError: false;
|
|
159
|
+
isRefetchError: false;
|
|
160
|
+
isFetchNextPageError: false;
|
|
161
|
+
isFetchPreviousPageError: false;
|
|
162
|
+
isSuccess: false;
|
|
163
|
+
isPlaceholderData: false;
|
|
164
|
+
status: "pending";
|
|
165
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
166
|
+
hasPreviousPage: boolean;
|
|
167
|
+
isFetchingPreviousPage: boolean;
|
|
168
|
+
dataUpdatedAt: number;
|
|
169
|
+
errorUpdatedAt: number;
|
|
170
|
+
failureCount: number;
|
|
171
|
+
failureReason: Error | null;
|
|
172
|
+
errorUpdateCount: number;
|
|
173
|
+
isFetched: boolean;
|
|
174
|
+
isFetchedAfterMount: boolean;
|
|
175
|
+
isFetching: boolean;
|
|
176
|
+
isInitialLoading: boolean;
|
|
177
|
+
isPaused: boolean;
|
|
178
|
+
isRefetching: boolean;
|
|
179
|
+
isStale: boolean;
|
|
180
|
+
isEnabled: boolean;
|
|
181
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
182
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
183
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>>;
|
|
184
|
+
data: import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown> | undefined;
|
|
185
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
186
|
+
hasNextPage: boolean;
|
|
187
|
+
isFetchingNextPage: boolean;
|
|
188
|
+
isLoading: boolean;
|
|
189
|
+
groupedData: Record<string, MediaCollectionItem[]>;
|
|
190
|
+
dataFlatten: MediaCollectionItem[];
|
|
191
|
+
} | {
|
|
192
|
+
isError: false;
|
|
193
|
+
error: null;
|
|
194
|
+
isPending: false;
|
|
195
|
+
isLoadingError: false;
|
|
196
|
+
isRefetchError: false;
|
|
197
|
+
isSuccess: true;
|
|
198
|
+
isPlaceholderData: true;
|
|
199
|
+
isFetchNextPageError: false;
|
|
200
|
+
isFetchPreviousPageError: false;
|
|
201
|
+
status: "success";
|
|
202
|
+
fetchPreviousPage: (options?: import("@tanstack/react-query").FetchPreviousPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
203
|
+
hasPreviousPage: boolean;
|
|
204
|
+
isFetchingPreviousPage: boolean;
|
|
205
|
+
dataUpdatedAt: number;
|
|
206
|
+
errorUpdatedAt: number;
|
|
207
|
+
failureCount: number;
|
|
208
|
+
failureReason: Error | null;
|
|
209
|
+
errorUpdateCount: number;
|
|
210
|
+
isFetched: boolean;
|
|
211
|
+
isFetchedAfterMount: boolean;
|
|
212
|
+
isFetching: boolean;
|
|
213
|
+
isInitialLoading: boolean;
|
|
214
|
+
isPaused: boolean;
|
|
215
|
+
isRefetching: boolean;
|
|
216
|
+
isStale: boolean;
|
|
217
|
+
isEnabled: boolean;
|
|
218
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
219
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
220
|
+
promise: Promise<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>>;
|
|
221
|
+
data: import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown> | undefined;
|
|
222
|
+
fetchNextPage: (options?: import("@tanstack/react-query").FetchNextPageOptions) => Promise<import("@tanstack/react-query").InfiniteQueryObserverResult<import("@tanstack/react-query").InfiniteData<MediaCollectionResponse, unknown>, Error>>;
|
|
223
|
+
hasNextPage: boolean;
|
|
224
|
+
isFetchingNextPage: boolean;
|
|
225
|
+
isLoading: boolean;
|
|
226
|
+
groupedData: Record<string, MediaCollectionItem[]>;
|
|
227
|
+
dataFlatten: MediaCollectionItem[];
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=useMediaCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaCollection.d.ts","sourceRoot":"","sources":["../../../src/hooks/collection/useMediaCollection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EACL,mBAAmB,EAEnB,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AAIzB,eAAO,MAAM,kBAAkB,GAAI,0BAGhC;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEA,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
13
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
14
|
+
import { apiInstance } from "../../services/api";
|
|
15
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
16
|
+
import { useMemo } from "react";
|
|
17
|
+
import dayjs from "dayjs";
|
|
18
|
+
export const useMediaCollection = ({ recvID, contentType, }) => {
|
|
19
|
+
const _a = useInfiniteQuery({
|
|
20
|
+
initialPageParam: 1,
|
|
21
|
+
queryKey: [QUERY_KEYS.GET_IMAGE_COLLECTION, recvID, contentType],
|
|
22
|
+
queryFn: async ({ pageParam = 1 }) => {
|
|
23
|
+
const params = {
|
|
24
|
+
contentType,
|
|
25
|
+
recvID,
|
|
26
|
+
page: pageParam,
|
|
27
|
+
pageSize: 50,
|
|
28
|
+
};
|
|
29
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.getMediaCollection, params);
|
|
30
|
+
return res.data;
|
|
31
|
+
},
|
|
32
|
+
getNextPageParam: (lastPage) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const currentPage = (_a = lastPage === null || lastPage === void 0 ? void 0 : lastPage.pageable) === null || _a === void 0 ? void 0 : _a.pageNumber;
|
|
35
|
+
const totalPages = (_b = lastPage === null || lastPage === void 0 ? void 0 : lastPage.pageable) === null || _b === void 0 ? void 0 : _b.totalPages;
|
|
36
|
+
return currentPage + 1 < totalPages ? currentPage + 1 : undefined;
|
|
37
|
+
},
|
|
38
|
+
enabled: !!recvID,
|
|
39
|
+
}), { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } = _a, rest = __rest(_a, ["data", "fetchNextPage", "hasNextPage", "isFetchingNextPage", "isLoading"]);
|
|
40
|
+
const { groupedData, dataFlatten } = useMemo(() => {
|
|
41
|
+
if (!data)
|
|
42
|
+
return {
|
|
43
|
+
groupedData: {},
|
|
44
|
+
dataFlatten: [],
|
|
45
|
+
};
|
|
46
|
+
const allItems = data.pages.flatMap((page) => page.data);
|
|
47
|
+
const mGroupeddata = allItems.reduce((acc, item) => {
|
|
48
|
+
const dateKey = dayjs(item.chatLog.sendTime).format("YYYY-MM-DD");
|
|
49
|
+
if (!acc[dateKey])
|
|
50
|
+
acc[dateKey] = [];
|
|
51
|
+
acc[dateKey].push(item);
|
|
52
|
+
return acc;
|
|
53
|
+
}, {});
|
|
54
|
+
return {
|
|
55
|
+
groupedData: mGroupeddata,
|
|
56
|
+
dataFlatten: allItems,
|
|
57
|
+
};
|
|
58
|
+
}, [data]);
|
|
59
|
+
return Object.assign({ data,
|
|
60
|
+
fetchNextPage,
|
|
61
|
+
hasNextPage,
|
|
62
|
+
isFetchingNextPage,
|
|
63
|
+
isLoading,
|
|
64
|
+
groupedData,
|
|
65
|
+
dataFlatten }, rest);
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMobile.d.ts","sourceRoot":"","sources":["../../../src/hooks/common/useIsMobile.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,GAAI,aAAY,MAAY,YAanD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export const useIsMobile = (breakpoint = 768) => {
|
|
4
|
+
const [isMobile, setIsMobile] = useState(() => {
|
|
5
|
+
if (typeof window === "undefined")
|
|
6
|
+
return false;
|
|
7
|
+
return window.innerWidth < breakpoint;
|
|
8
|
+
});
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const handleResize = () => setIsMobile(window.innerWidth < breakpoint);
|
|
11
|
+
window.addEventListener("resize", handleResize);
|
|
12
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
13
|
+
}, [breakpoint]);
|
|
14
|
+
return isMobile;
|
|
15
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ConversationItem } from "@openim/wasm-client-sdk";
|
|
1
2
|
interface ConversationStore {
|
|
2
|
-
conversationData:
|
|
3
|
-
setConversationData: (data:
|
|
3
|
+
conversationData: ConversationItem | null;
|
|
4
|
+
setConversationData: (data: ConversationItem) => void;
|
|
4
5
|
selectedThreadId: string;
|
|
5
6
|
selectedSourceId: string;
|
|
6
7
|
setSelectedThreadId: (threadId: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversationStore.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversationStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useConversationStore.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversationStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,UAAU,iBAAiB;IACzB,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,mBAAmB,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED,QAAA,MAAM,oBAAoB,gFAOvB,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,YA0N1B,CAAC"}
|