@webinex/chatify 2.0.0-build2 → 2.0.0-build3
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/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/api/accountApi.d.ts +0 -1
- package/dist/esm/types/core/api/api.d.ts +2 -0
- package/dist/esm/types/core/api/baseApi.d.ts +2 -1
- package/dist/esm/types/core/api/chatApi.d.ts +0 -11
- package/dist/esm/types/core/api/chatListApi.d.ts +0 -1
- package/dist/esm/types/core/api/chatMemberApi.d.ts +0 -1
- package/dist/esm/types/core/api/chatMessageApi.d.ts +0 -12
- package/dist/esm/types/core/api/index.d.ts +0 -8
- package/dist/esm/types/core/api/threadApi.d.ts +2 -10
- package/dist/esm/types/core/api/threadMessageApi.d.ts +0 -9
- package/dist/index.d.ts +3176 -0
- package/package.json +2 -2
- package/src/core/api/accountApi.ts +0 -2
- package/src/core/api/api.ts +2 -2
- package/src/core/api/baseApi.ts +12 -7
- package/src/core/api/chatApi.ts +1 -7
- package/src/core/api/chatListApi.ts +0 -2
- package/src/core/api/chatMemberApi.ts +0 -2
- package/src/core/api/chatMessageApi.ts +0 -9
- package/src/core/api/index.ts +0 -8
- package/src/core/api/threadApi.ts +1 -9
- package/src/core/api/threadMessageApi.ts +0 -9
- package/src/ui/Chat/ChatEditableHeaderName.tsx +2 -2
- package/src/ui/Chat/ChatPanel.tsx +2 -2
- package/src/ui/Chat/ChatView.tsx +6 -14
- package/src/ui/Chat/Members/ChatMembersPanel.tsx +7 -12
- package/src/ui/Chat/Members/ChatMembersPreview.tsx +2 -2
- package/src/ui/ChatGroup/ChatGroupPanel.tsx +2 -2
- package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +2 -2
- package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +2 -2
- package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +2 -2
- package/src/ui/ChatGroup/List/ChatList.tsx +2 -2
- package/src/ui/Thread/ThreadPanel.tsx +8 -19
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"name": "@webinex/chatify",
|
|
3
3
|
"description": "Webinex Wispo",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "2.0.0-
|
|
5
|
+
"version": "2.0.0-build3",
|
|
6
6
|
"author": "Webinex Dev",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/cjs/index.js",
|
|
9
9
|
"module": "dist/esm/index.js",
|
|
10
|
-
"types": "dist/
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"targets": {
|
|
13
13
|
"demo": {
|
package/src/core/api/api.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { __chatApi } from './chatApi';
|
|
|
4
4
|
import { __baseApi, __settings } from './baseApi';
|
|
5
5
|
import { __chatMessageApi } from './chatMessageApi';
|
|
6
6
|
import { __chatMemberApi } from './chatMemberApi';
|
|
7
|
-
import { __chatListApi } from './chatListApi';
|
|
7
|
+
import { __chatListApi, useChatListItem } from './chatListApi';
|
|
8
8
|
import { __threadApi } from './threadApi';
|
|
9
9
|
import { __threadMessageApi } from './threadMessageApi';
|
|
10
10
|
|
|
@@ -39,4 +39,4 @@ const api: Api<
|
|
|
39
39
|
GetApiTypes<typeof __baseApi>[4]
|
|
40
40
|
> = __baseApi as any;
|
|
41
41
|
|
|
42
|
-
export const chatifyApi = Object.assign(api, { settings: __settings });
|
|
42
|
+
export const chatifyApi = Object.assign(api, { settings: __settings, useChatListItem });
|
package/src/core/api/baseApi.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
1
|
+
import { BaseQueryFn, createApi, fakeBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
2
2
|
import { ChatifyClient } from '../client';
|
|
3
3
|
import { Debounce } from '../debounce';
|
|
4
4
|
import { chatId } from '../types';
|
|
@@ -22,9 +22,14 @@ export const __settings: ChatifyApiSettings = {
|
|
|
22
22
|
client: null!,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
const TAG_TYPES = ['chat', 'account', 'message', 'thread', 'thread-message'] as const;
|
|
26
|
+
|
|
27
|
+
const baseApi: ReturnType<typeof createApi<BaseQueryFn, {}, 'chatify', (typeof TAG_TYPES)[number]>> =
|
|
28
|
+
createApi({
|
|
29
|
+
baseQuery: fakeBaseQuery(),
|
|
30
|
+
reducerPath: 'chatify',
|
|
31
|
+
tagTypes: TAG_TYPES,
|
|
32
|
+
endpoints: (_) => ({}),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const __baseApi = baseApi;
|
package/src/core/api/chatApi.ts
CHANGED
|
@@ -7,10 +7,7 @@ const chatApi = __baseApi.injectEndpoints({
|
|
|
7
7
|
getChat: builder.query<Chat, { id: string }>({
|
|
8
8
|
queryFn: async ({ id }) => ({ data: await __settings.client.chat(id) }),
|
|
9
9
|
providesTags: ['chat', 'account'],
|
|
10
|
-
onCacheEntryAdded: async (
|
|
11
|
-
{ id },
|
|
12
|
-
{ dispatch, cacheEntryRemoved, cacheDataLoaded, updateCachedData },
|
|
13
|
-
) => {
|
|
10
|
+
onCacheEntryAdded: async ({ id }, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
|
|
14
11
|
await cacheDataLoaded;
|
|
15
12
|
|
|
16
13
|
unsubscribe(
|
|
@@ -84,6 +81,3 @@ const chatApi = __baseApi.injectEndpoints({
|
|
|
84
81
|
});
|
|
85
82
|
|
|
86
83
|
export const __chatApi = chatApi;
|
|
87
|
-
|
|
88
|
-
export const { useGetChatQuery, useLazyGetChatQuery, useAddChatMutation, useUpdateChatNameMutation } =
|
|
89
|
-
chatApi;
|
|
@@ -145,12 +145,3 @@ export const __chatMessageApi = __baseApi.injectEndpoints({
|
|
|
145
145
|
}),
|
|
146
146
|
}),
|
|
147
147
|
});
|
|
148
|
-
|
|
149
|
-
export const {
|
|
150
|
-
useFetchNextChatMessageListMutation,
|
|
151
|
-
useGetChatMessageListQuery,
|
|
152
|
-
useReadChatMessageMutation,
|
|
153
|
-
useSendChatMessageMutation,
|
|
154
|
-
useGetChatMessageReadQueueQuery,
|
|
155
|
-
useLazyGetChatMessageListQuery,
|
|
156
|
-
} = __chatMessageApi;
|
package/src/core/api/index.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export * from './baseApi';
|
|
2
|
-
export * from './accountApi';
|
|
3
|
-
export * from './chatApi';
|
|
4
|
-
export * from './chatListApi';
|
|
5
|
-
export * from './chatMemberApi';
|
|
6
|
-
export * from './chatMessageApi';
|
|
7
|
-
export * from './threadApi';
|
|
8
|
-
export * from './threadMessageApi';
|
|
9
1
|
export * from './api';
|
|
@@ -118,15 +118,7 @@ export const __threadApi = __baseApi.injectEndpoints({
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
export function useUnreadThreadMessageCount() {
|
|
121
|
-
const { data: threads, ...state } = useGetWatchThreadListQuery();
|
|
121
|
+
const { data: threads, ...state } = __threadApi.useGetWatchThreadListQuery();
|
|
122
122
|
const count = useMemo(() => (threads != null ? calcThreadListUnreadCount(threads) : null), [threads]);
|
|
123
123
|
return [count, state] as const;
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
export const {
|
|
127
|
-
useGetWatchThreadListQuery,
|
|
128
|
-
useGetThreadQuery,
|
|
129
|
-
useLazyGetThreadQuery,
|
|
130
|
-
useLazyGetWatchThreadListQuery,
|
|
131
|
-
useWatchThreadMutation,
|
|
132
|
-
} = __threadApi;
|
|
@@ -116,12 +116,3 @@ export const __threadMessageApi = __baseApi.injectEndpoints({
|
|
|
116
116
|
}),
|
|
117
117
|
}),
|
|
118
118
|
});
|
|
119
|
-
|
|
120
|
-
export const {
|
|
121
|
-
useFetchNextThreadMessageListMutation,
|
|
122
|
-
useGetThreadMessageListQuery,
|
|
123
|
-
useLazyGetThreadMessageListQuery,
|
|
124
|
-
useReadThreadMessageMutation,
|
|
125
|
-
useSendThreadMessageMutation,
|
|
126
|
-
useGetThreadMessageReadQueueQuery,
|
|
127
|
-
} = __threadMessageApi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Input, Tooltip } from 'antd';
|
|
2
|
-
import {
|
|
2
|
+
import { chatifyApi } from '../../core';
|
|
3
3
|
import { customize } from '../customize';
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import isHotkey from 'is-hotkey';
|
|
@@ -9,7 +9,7 @@ const isEscape = isHotkey('escape');
|
|
|
9
9
|
const isEnter = isHotkey('enter');
|
|
10
10
|
|
|
11
11
|
function useUpdateChatName(id: string, value: string) {
|
|
12
|
-
const [updateChatName] = useUpdateChatNameMutation();
|
|
12
|
+
const [updateChatName] = chatifyApi.useUpdateChatNameMutation();
|
|
13
13
|
return () => updateChatName({ id, name: value });
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -2,7 +2,7 @@ import { CSSProperties } from 'react';
|
|
|
2
2
|
import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
|
|
3
3
|
import { CustomizeContext } from '../customize';
|
|
4
4
|
import { ChatView, ChatViewCustomizeValue } from './ChatView';
|
|
5
|
-
import {
|
|
5
|
+
import { chatifyApi } from '../../core';
|
|
6
6
|
|
|
7
7
|
export interface ChatPanelCustomizeValue extends ChatViewCustomizeValue {}
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ export interface ChatPanelProps {
|
|
|
16
16
|
|
|
17
17
|
export function ChatPanel(props: ChatPanelProps) {
|
|
18
18
|
const { id, className = '', customize, localizer = defaultLocalizer, style } = props;
|
|
19
|
-
const { data: chat } = useGetChatQuery({ id });
|
|
19
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<div className={`wxchtf-chatify wxchtf-chat-panel ${className}`} style={style}>
|
package/src/ui/Chat/ChatView.tsx
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { CustomizeContext, customize, useCustomizeContext } from '../customize';
|
|
2
|
-
import {
|
|
3
|
-
MessageBody,
|
|
4
|
-
chatId,
|
|
5
|
-
useFetchNextChatMessageListMutation,
|
|
6
|
-
useGetChatMessageListQuery,
|
|
7
|
-
useGetChatMessageReadQueueQuery,
|
|
8
|
-
useReadChatMessageMutation,
|
|
9
|
-
useSendChatMessageMutation,
|
|
10
|
-
} from '../../core';
|
|
2
|
+
import { MessageBody, chatId, chatifyApi } from '../../core';
|
|
11
3
|
import {
|
|
12
4
|
Conversation,
|
|
13
5
|
ConversationCustomizeValue,
|
|
@@ -41,19 +33,19 @@ function useConversation(props: ChatProps) {
|
|
|
41
33
|
const { value: chat } = props;
|
|
42
34
|
const { id, name, active, lastReadMessageId } = chat;
|
|
43
35
|
|
|
44
|
-
const { data: messageList } = useGetChatMessageListQuery({ chatId: id });
|
|
36
|
+
const { data: messageList } = chatifyApi.useGetChatMessageListQuery({ chatId: id });
|
|
45
37
|
const { messages, hasMore } = messageList ?? {};
|
|
46
38
|
|
|
47
|
-
const [fetchNext, { isLoading: isFetchNextLoading }] = useFetchNextChatMessageListMutation();
|
|
39
|
+
const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextChatMessageListMutation();
|
|
48
40
|
const onNext = useCallback(() => fetchNext({ chatId: id }), [fetchNext, id]);
|
|
49
41
|
|
|
50
|
-
const [read] = useReadChatMessageMutation();
|
|
42
|
+
const [read] = chatifyApi.useReadChatMessageMutation();
|
|
51
43
|
const onRead = useCallback((id: string) => read({ id }), [read]);
|
|
52
44
|
|
|
53
|
-
const [send] = useSendChatMessageMutation();
|
|
45
|
+
const [send] = chatifyApi.useSendChatMessageMutation();
|
|
54
46
|
const onSend = useCallback((message: MessageBody) => send({ ...message, chatId: id }).unwrap(), [id, send]);
|
|
55
47
|
|
|
56
|
-
const { data: readQueue } = useGetChatMessageReadQueueQuery();
|
|
48
|
+
const { data: readQueue } = chatifyApi.useGetChatMessageReadQueueQuery();
|
|
57
49
|
|
|
58
50
|
const conversation = useMemo(() => {
|
|
59
51
|
if (!id) {
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Button, List, Space, Tooltip } from 'antd';
|
|
2
|
-
import {
|
|
3
|
-
useAddChatMemberMutation,
|
|
4
|
-
useGetAccountListQuery,
|
|
5
|
-
useGetChatQuery,
|
|
6
|
-
useRemoveChatMemberMutation,
|
|
7
|
-
} from '../../../core';
|
|
2
|
+
import { chatifyApi } from '../../../core';
|
|
8
3
|
import { customize } from '../../customize';
|
|
9
4
|
import { useCallback, useMemo } from 'react';
|
|
10
5
|
import { Icon } from '../../common/Icon';
|
|
@@ -17,7 +12,7 @@ interface ChatMemberListItemProps {
|
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
function useAdd(chatId: string, accountId: string, withHistory: boolean) {
|
|
20
|
-
const [add, state] = useAddChatMemberMutation();
|
|
15
|
+
const [add, state] = chatifyApi.useAddChatMemberMutation();
|
|
21
16
|
const onAdd = useCallback(
|
|
22
17
|
() => add({ chatId, accountId, withHistory }),
|
|
23
18
|
[add, chatId, accountId, withHistory],
|
|
@@ -26,7 +21,7 @@ function useAdd(chatId: string, accountId: string, withHistory: boolean) {
|
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
function useRemove(chatId: string, accountId: string, deleteHistory: boolean) {
|
|
29
|
-
const [remove, state] = useRemoveChatMemberMutation();
|
|
24
|
+
const [remove, state] = chatifyApi.useRemoveChatMemberMutation();
|
|
30
25
|
const onRemove = useCallback(
|
|
31
26
|
() => remove({ chatId, accountId, deleteHistory }),
|
|
32
27
|
[remove, chatId, accountId, deleteHistory],
|
|
@@ -36,8 +31,8 @@ function useRemove(chatId: string, accountId: string, deleteHistory: boolean) {
|
|
|
36
31
|
|
|
37
32
|
const ChatMemberListItem = customize('ChatMemberListItem', (props: ChatMemberListItemProps) => {
|
|
38
33
|
const { chatId } = props;
|
|
39
|
-
const { data: chat } = useGetChatQuery({ id: chatId });
|
|
40
|
-
const { data: accounts } = useGetAccountListQuery();
|
|
34
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id: chatId });
|
|
35
|
+
const { data: accounts } = chatifyApi.useGetAccountListQuery();
|
|
41
36
|
const account = accounts!.find((x) => x.id === props.id)!;
|
|
42
37
|
const isMember = chat!.members.some((x) => x.id === account.id);
|
|
43
38
|
const [onAddWithoutHistory] = useAdd(chatId, account.id, false);
|
|
@@ -86,8 +81,8 @@ const ChatMemberListItem = customize('ChatMemberListItem', (props: ChatMemberLis
|
|
|
86
81
|
|
|
87
82
|
export const ChatMembersPanel = customize('ChatMembersPanel', () => {
|
|
88
83
|
const { id } = useChatContext();
|
|
89
|
-
const { data: chat } = useGetChatQuery({ id });
|
|
90
|
-
const { data: accounts } = useGetAccountListQuery();
|
|
84
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
85
|
+
const { data: accounts } = chatifyApi.useGetAccountListQuery();
|
|
91
86
|
const ordered = useMemo(
|
|
92
87
|
() =>
|
|
93
88
|
accounts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { chatifyApi } from '../../../core';
|
|
2
2
|
import { Tooltip } from 'antd';
|
|
3
3
|
import { customize } from '../../customize';
|
|
4
4
|
import { Avatar as AntdAvatar } from 'antd';
|
|
@@ -7,7 +7,7 @@ import { useChatContext } from '../ChatContext';
|
|
|
7
7
|
|
|
8
8
|
export const ChatMembersPreview = customize('ChatMembersPreview', () => {
|
|
9
9
|
const { id } = useChatContext();
|
|
10
|
-
const { data: chat } = useGetChatQuery({ id });
|
|
10
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
11
11
|
|
|
12
12
|
if (!chat?.members) {
|
|
13
13
|
return null;
|
|
@@ -4,7 +4,7 @@ import { CreateChatPanelCustomizeValue } from './Create';
|
|
|
4
4
|
import { ChatGroupBody, ChatGroupFooter, ChatGroupHeader, ChatGroupLayoutCustomizeValue } from './Layout';
|
|
5
5
|
import { ChatListCustomizeValue } from './List';
|
|
6
6
|
import { ChatGroupContext, useChatGroupContext } from './ChatGroupContext';
|
|
7
|
-
import {
|
|
7
|
+
import { chatifyApi } from '../../core';
|
|
8
8
|
import { CustomizeContext } from '../customize';
|
|
9
9
|
import { ChatViewCustomizeValue } from '../Chat';
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ export interface ChatifyProps {
|
|
|
23
23
|
|
|
24
24
|
function Content(props: Pick<ChatifyProps, 'className' | 'style'>) {
|
|
25
25
|
const { className = '', style } = props;
|
|
26
|
-
const { data: chats } = useGetChatListQuery();
|
|
26
|
+
const { data: chats } = chatifyApi.useGetChatListQuery();
|
|
27
27
|
const { openChat, none, chatId } = useChatGroupContext();
|
|
28
28
|
const openFirstChatRef = useRef(false);
|
|
29
29
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import { chatifyApi
|
|
2
|
+
import { chatifyApi } from '../../../core';
|
|
3
3
|
import { customize } from '../../customize';
|
|
4
4
|
import { Checkbox, Form, List } from 'antd';
|
|
5
5
|
import { useLocalizer } from '../../localizer';
|
|
@@ -16,7 +16,7 @@ interface CheckboxListProps {
|
|
|
16
16
|
|
|
17
17
|
function CheckboxList(props: CheckboxListProps) {
|
|
18
18
|
const { value, onChange } = props;
|
|
19
|
-
const { data: accounts, isFetching } = useGetAccountListQuery();
|
|
19
|
+
const { data: accounts, isFetching } = chatifyApi.useGetAccountListQuery();
|
|
20
20
|
const me = chatifyApi.settings.me();
|
|
21
21
|
const dataSource = useMemo(() => accounts?.filter((x) => x.id !== me) ?? [], [accounts, me]);
|
|
22
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { chatifyApi } from '../../../core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { useLocalizer } from '../../localizer';
|
|
4
4
|
import { CreateChatForm, CreateChatFormValue } from './CreateChatForm';
|
|
@@ -8,7 +8,7 @@ import { Icon } from '../../common/Icon';
|
|
|
8
8
|
import { useChatGroupContext } from '../ChatGroupContext';
|
|
9
9
|
|
|
10
10
|
function useSubmit() {
|
|
11
|
-
const [add, { isLoading }] = useAddChatMutation();
|
|
11
|
+
const [add, { isLoading }] = chatifyApi.useAddChatMutation();
|
|
12
12
|
const { openChat } = useChatGroupContext();
|
|
13
13
|
|
|
14
14
|
const onSubmit = useCallback(
|
|
@@ -2,11 +2,11 @@ import { customize } from '../../customize';
|
|
|
2
2
|
import { CreateChatPanel } from '../Create';
|
|
3
3
|
import { ChatView } from '../../Chat';
|
|
4
4
|
import { useChatGroupContext } from '../ChatGroupContext';
|
|
5
|
-
import {
|
|
5
|
+
import { chatifyApi } from '../../../core';
|
|
6
6
|
|
|
7
7
|
export const ChatGroupMain = customize('ChatGroupMain', () => {
|
|
8
8
|
const { chatId, view } = useChatGroupContext();
|
|
9
|
-
const chat = useChatListItem(chatId);
|
|
9
|
+
const chat = chatifyApi.useChatListItem(chatId);
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
12
|
<div className="wxchtf-main">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Menu, MenuProps } from 'antd';
|
|
2
2
|
import { useCallback, useMemo } from 'react';
|
|
3
3
|
import type { MenuItemType } from 'antd/es/menu/hooks/useItems';
|
|
4
|
-
import {
|
|
4
|
+
import { chatifyApi } from '../../../core';
|
|
5
5
|
import { ChatListItemBox } from './ChatListItemBox';
|
|
6
6
|
import { customize } from '../../customize';
|
|
7
7
|
import { useChatGroupContext } from '../ChatGroupContext';
|
|
@@ -16,7 +16,7 @@ function useOnSelect() {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function useMenuItems() {
|
|
19
|
-
const { data: chats } = useGetChatListQuery();
|
|
19
|
+
const { data: chats } = chatifyApi.useGetChatListQuery();
|
|
20
20
|
|
|
21
21
|
return useMemo<MenuItemType[] | undefined>(() => {
|
|
22
22
|
return chats
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
MessageBody,
|
|
4
|
-
chatifyApi,
|
|
5
|
-
parseThreadMessageId,
|
|
6
|
-
useFetchNextThreadMessageListMutation,
|
|
7
|
-
useGetThreadMessageListQuery,
|
|
8
|
-
useGetThreadMessageReadQueueQuery,
|
|
9
|
-
useGetThreadQuery,
|
|
10
|
-
useReadThreadMessageMutation,
|
|
11
|
-
useSendThreadMessageMutation,
|
|
12
|
-
useWatchThreadMutation,
|
|
13
|
-
} from '../../core';
|
|
2
|
+
import { MessageBody, chatifyApi, parseThreadMessageId } from '../../core';
|
|
14
3
|
import { Conversation, ConversationCustomizeValue, ConversationProps } from '../Conversation';
|
|
15
4
|
import { ThreadContext, ThreadContextValue } from './ThreadContext';
|
|
16
5
|
import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
|
|
@@ -31,24 +20,24 @@ export interface ThreadPanelProps {
|
|
|
31
20
|
|
|
32
21
|
function usePanelState(props: ThreadPanelProps) {
|
|
33
22
|
const { threadId } = props;
|
|
34
|
-
const { data: thread } = useGetThreadQuery({ id: threadId });
|
|
35
|
-
const { data: messageList } = useGetThreadMessageListQuery({ threadId });
|
|
23
|
+
const { data: thread } = chatifyApi.useGetThreadQuery({ id: threadId });
|
|
24
|
+
const { data: messageList } = chatifyApi.useGetThreadMessageListQuery({ threadId });
|
|
36
25
|
const { id, name, archive, lastReadMessageId, watch } = thread ?? {};
|
|
37
26
|
const { messages, hasMore } = messageList ?? {};
|
|
38
27
|
|
|
39
|
-
const [read] = useReadThreadMessageMutation();
|
|
28
|
+
const [read] = chatifyApi.useReadThreadMessageMutation();
|
|
40
29
|
const onRead = useCallback((id: string) => read({ id }), [read]);
|
|
41
30
|
|
|
42
|
-
const [fetchNext, { isLoading: isFetchNextLoading }] = useFetchNextThreadMessageListMutation();
|
|
31
|
+
const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextThreadMessageListMutation();
|
|
43
32
|
const onNext = useCallback(() => fetchNext({ threadId }), [fetchNext, threadId]);
|
|
44
33
|
|
|
45
|
-
const [send] = useSendThreadMessageMutation();
|
|
34
|
+
const [send] = chatifyApi.useSendThreadMessageMutation();
|
|
46
35
|
const onSend = useCallback(
|
|
47
36
|
(message: MessageBody) => send({ body: message, threadId }).unwrap(),
|
|
48
37
|
[threadId, send],
|
|
49
38
|
);
|
|
50
39
|
|
|
51
|
-
const { data: readQueue } = useGetThreadMessageReadQueueQuery();
|
|
40
|
+
const { data: readQueue } = chatifyApi.useGetThreadMessageReadQueueQuery();
|
|
52
41
|
|
|
53
42
|
const conversation = useMemo(() => {
|
|
54
43
|
if (!id) {
|
|
@@ -86,7 +75,7 @@ function usePanelState(props: ThreadPanelProps) {
|
|
|
86
75
|
watch,
|
|
87
76
|
]);
|
|
88
77
|
|
|
89
|
-
const [watchThread] = useWatchThreadMutation();
|
|
78
|
+
const [watchThread] = chatifyApi.useWatchThreadMutation();
|
|
90
79
|
|
|
91
80
|
const threadContext = useMemo<ThreadContextValue | null>(
|
|
92
81
|
() =>
|