@droppii-org/chat-sdk 0.0.30 → 0.0.32
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/ConversationBySessionItem.d.ts +7 -0
- package/dist/components/conversation/ConversationBySessionItem.d.ts.map +1 -0
- package/dist/components/conversation/ConversationBySessionItem.js +97 -0
- 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 +33 -87
- 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 +52 -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 +51 -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 +50 -0
- package/dist/components/mediaCollection/index.d.ts +10 -0
- package/dist/components/mediaCollection/index.d.ts.map +1 -0
- package/dist/components/mediaCollection/index.js +58 -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.d.ts.map +1 -1
- package/dist/components/message/footer/ToolbarPlugin.js +3 -6
- 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/searchConversation/SearchAll.d.ts +3 -0
- package/dist/components/searchConversation/SearchAll.d.ts.map +1 -0
- package/dist/components/searchConversation/SearchAll.js +8 -0
- package/dist/components/searchConversation/SearchConversationAsMessages.d.ts +3 -0
- package/dist/components/searchConversation/SearchConversationAsMessages.d.ts.map +1 -0
- package/dist/components/searchConversation/SearchConversationAsMessages.js +8 -0
- package/dist/components/searchConversation/SearchConversationAsUsers.d.ts +3 -0
- package/dist/components/searchConversation/SearchConversationAsUsers.d.ts.map +1 -0
- package/dist/components/searchConversation/SearchConversationAsUsers.js +8 -0
- package/dist/components/searchConversation/index.d.ts +8 -0
- package/dist/components/searchConversation/index.d.ts.map +1 -0
- package/dist/components/searchConversation/index.js +38 -0
- package/dist/components/session/AssignedSessionFilter.js +9 -10
- package/dist/components/session/DeskAssignedSession.d.ts +3 -0
- package/dist/components/session/DeskAssignedSession.d.ts.map +1 -0
- package/dist/components/session/DeskAssignedSession.js +118 -0
- 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/useConversation.js +1 -1
- 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/hooks/search/useSearchConversation.d.ts +2 -0
- package/dist/hooks/search/useSearchConversation.d.ts.map +1 -0
- package/dist/hooks/search/useSearchConversation.js +1 -0
- package/dist/hooks/session/useGetSessionByTagOrStatus.d.ts +220 -0
- package/dist/hooks/session/useGetSessionByTagOrStatus.d.ts.map +1 -0
- package/dist/hooks/session/useGetSessionByTagOrStatus.js +72 -0
- package/dist/hooks/session/useGetSessionSummary.d.ts +3 -0
- package/dist/hooks/session/useGetSessionSummary.d.ts.map +1 -0
- package/dist/hooks/session/useGetSessionSummary.js +14 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- 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 +24 -0
- package/dist/screens/chatBubble/index.d.ts.map +1 -1
- package/dist/screens/chatBubble/index.js +20 -10
- package/dist/screens/deskMessage/index.d.ts.map +1 -1
- package/dist/screens/deskMessage/index.js +4 -4
- 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 +7 -0
- package/dist/services/query.d.ts.map +1 -0
- package/dist/services/query.js +6 -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/store/conversation.d.ts.map +1 -1
- package/dist/store/conversation.js +0 -11
- package/dist/store/session.d.ts +8 -0
- package/dist/store/session.d.ts.map +1 -0
- package/dist/store/session.js +10 -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 +55 -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
|
@@ -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
|
+
};
|
|
@@ -62,7 +62,7 @@ export const useConversationDisplayData = (conversation) => {
|
|
|
62
62
|
? `${userInfo === null || userInfo === void 0 ? void 0 : userInfo.nickname}${((_c = (_b = exUserInfo === null || exUserInfo === void 0 ? void 0 : exUserInfo.userInfo) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.username)
|
|
63
63
|
? ` (${(_e = (_d = exUserInfo === null || exUserInfo === void 0 ? void 0 : exUserInfo.userInfo) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.username})`
|
|
64
64
|
: ""}`
|
|
65
|
-
: conversation === null || conversation === void 0 ? void 0 : conversation.showName,
|
|
65
|
+
: (conversation === null || conversation === void 0 ? void 0 : conversation.showName) || "",
|
|
66
66
|
};
|
|
67
67
|
}, [conversation, userInfo]);
|
|
68
68
|
return Object.assign({}, conversationDisplayData);
|
|
@@ -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"}
|
|
@@ -5,12 +5,17 @@ import { ConnectStatus, CustomType, SyncStatus } from "../../types/chat";
|
|
|
5
5
|
import { pushNewMessage, updateOneMessage } from "../message/useMessage";
|
|
6
6
|
import { useChatContext } from "../../context/ChatContext";
|
|
7
7
|
import useConversationStore from "../../store/conversation";
|
|
8
|
+
import useAuthStore from "../../store/auth";
|
|
9
|
+
import { useRefetchChatToken } from "../../hooks/init/useChatToken";
|
|
8
10
|
const notPushType = [MessageType.TypingMessage, MessageType.RevokeMessage];
|
|
9
11
|
export const useGlobalEvent = () => {
|
|
10
12
|
const { user } = useChatContext();
|
|
11
|
-
const { updateConnectStatus, updateSyncStatus } = useChatContext();
|
|
13
|
+
const { updateConnectStatus, updateSyncStatus, getSelfUserInfo } = useChatContext();
|
|
12
14
|
const updateConversationList = useConversationStore((state) => state.updateConversationList);
|
|
13
15
|
const getConversationListByReq = useConversationStore((state) => state.getConversationListByReq);
|
|
16
|
+
const { mutate: refetchChatToken } = useRefetchChatToken();
|
|
17
|
+
const accessToken = useAuthStore((state) => state.accessToken);
|
|
18
|
+
const chatToken = useAuthStore((state) => state.chatToken);
|
|
14
19
|
const revokedMessageHandler = ({ data }) => {
|
|
15
20
|
updateOneMessage({
|
|
16
21
|
clientMsgID: data.clientMsgID,
|
|
@@ -52,8 +57,46 @@ export const useGlobalEvent = () => {
|
|
|
52
57
|
const newMessageHandler = ({ data }) => {
|
|
53
58
|
data.map((message) => handleNewMessage(message));
|
|
54
59
|
};
|
|
60
|
+
const userTokenHandler = () => {
|
|
61
|
+
refetchChatToken(undefined, {
|
|
62
|
+
onSettled(data) {
|
|
63
|
+
var _a;
|
|
64
|
+
if (data) {
|
|
65
|
+
useAuthStore.getState().setChatToken((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.token);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const initStore = () => {
|
|
71
|
+
getSelfUserInfo();
|
|
72
|
+
getConversationListByReq(false);
|
|
73
|
+
};
|
|
74
|
+
const tryLogin = async () => {
|
|
75
|
+
const { userID, chatToken, platformID, apiAddress, wsAddress } = useAuthStore.getState();
|
|
76
|
+
try {
|
|
77
|
+
await DChatSDK.login({
|
|
78
|
+
userID,
|
|
79
|
+
token: chatToken,
|
|
80
|
+
platformID,
|
|
81
|
+
apiAddr: `${apiAddress}/chat-service`,
|
|
82
|
+
wsAddr: `${wsAddress}/chat-service/ws`,
|
|
83
|
+
});
|
|
84
|
+
initStore();
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error(error);
|
|
88
|
+
if (error.errCode !== 10102) {
|
|
89
|
+
//user has logged in
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
55
93
|
const loginCheck = async () => {
|
|
56
|
-
|
|
94
|
+
const chatToken = useAuthStore.getState().chatToken;
|
|
95
|
+
const userID = useAuthStore.getState().userID;
|
|
96
|
+
if (!chatToken || !userID) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
tryLogin();
|
|
57
100
|
};
|
|
58
101
|
const connectingHandler = () => {
|
|
59
102
|
updateConnectStatus(ConnectStatus.Connecting);
|
|
@@ -64,9 +107,6 @@ export const useGlobalEvent = () => {
|
|
|
64
107
|
const connectFailedHandler = () => {
|
|
65
108
|
updateConnectStatus(ConnectStatus.Disconnected);
|
|
66
109
|
};
|
|
67
|
-
const userTokenHandler = () => {
|
|
68
|
-
useChatContext().userTokenHandler();
|
|
69
|
-
};
|
|
70
110
|
const syncStartHandler = ({ data }) => {
|
|
71
111
|
updateSyncStatus(SyncStatus.Loading);
|
|
72
112
|
};
|
|
@@ -126,7 +166,6 @@ export const useGlobalEvent = () => {
|
|
|
126
166
|
};
|
|
127
167
|
/** LIFE CYCLE */
|
|
128
168
|
useEffect(() => {
|
|
129
|
-
loginCheck();
|
|
130
169
|
setIMListener();
|
|
131
170
|
window.addEventListener("online", () => {
|
|
132
171
|
DChatSDK.networkStatusChanged();
|
|
@@ -138,4 +177,14 @@ export const useGlobalEvent = () => {
|
|
|
138
177
|
disposeIMListener();
|
|
139
178
|
};
|
|
140
179
|
}, []);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (!!accessToken) {
|
|
182
|
+
userTokenHandler();
|
|
183
|
+
}
|
|
184
|
+
}, [accessToken]);
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (!!chatToken) {
|
|
187
|
+
loginCheck();
|
|
188
|
+
}
|
|
189
|
+
}, [chatToken]);
|
|
141
190
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatToken.d.ts","sourceRoot":"","sources":["../../../src/hooks/init/useChatToken.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,oFAS5B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
export const useRefetchChatToken = () => useMutation({
|
|
6
|
+
mutationKey: [QUERY_KEYS.REFRESH_CHAT_TOKEN],
|
|
7
|
+
mutationFn: async () => {
|
|
8
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.getChatToken);
|
|
9
|
+
return res.data;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlC,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,cAAc,WAAW;gDAiCjD;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB;wDAwBE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,UAAU,EAAE,CAAC;KACrB;
|
|
1
|
+
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlC,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,cAAc,WAAW;gDAiCjD;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB;wDAwBE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,UAAU,EAAE,CAAC;KACrB;CA+IJ,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,2CAIvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,KAoBM,iBACN,CAAC"}
|