@webinex/chatify 1.0.0-rc2 → 1.0.0-rc3
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/css/chatify.css +183 -141
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/action.d.ts +110 -42
- package/dist/esm/types/core/client.d.ts +2 -1
- package/dist/esm/types/core/index.d.ts +11 -8
- package/dist/esm/types/core/models.d.ts +10 -4
- package/dist/esm/types/core/state.d.ts +36 -7
- package/dist/esm/types/core/useAddChatMutation.d.ts +2 -0
- package/dist/esm/types/core/useAddMemberMutation.d.ts +2 -0
- package/dist/esm/types/core/useFetchNextMutation.d.ts +3 -0
- package/dist/esm/types/core/useGetAccountsQuery.d.ts +1 -0
- package/dist/esm/types/core/useGetChatListQuery.d.ts +1 -0
- package/dist/{cjs/types/core/useChat.d.ts → esm/types/core/useGetChatQuery.d.ts} +1 -1
- package/dist/esm/types/core/useGetMessagesQuery.d.ts +4 -0
- package/dist/esm/types/core/useRemoveMemberMutation.d.ts +2 -0
- package/dist/esm/types/core/useSendMutation.d.ts +2 -0
- package/dist/esm/types/core/useUpdateChatNameMutation.d.ts +2 -0
- package/dist/esm/types/ui/AddChatButton.d.ts +2 -2
- package/dist/esm/types/ui/Avatar.d.ts +2 -2
- package/dist/esm/types/ui/ChatList/ChatList.d.ts +2 -0
- package/dist/esm/types/ui/ChatList/ChatListItemBox.d.ts +6 -0
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessage.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessageAuthor.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemLastMessageContent.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemName.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/ChatListItemUnreadCount.d.ts +3 -0
- package/dist/esm/types/ui/ChatList/index.d.ts +7 -0
- package/dist/esm/types/ui/ChatName.d.ts +2 -2
- package/dist/esm/types/ui/ChatPanel/ChatBody.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatHeader.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatHeaderMembers.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatHeaderName.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatMembersButton.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatMembersPanel.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/ChatPanel.d.ts +5 -0
- package/dist/esm/types/ui/ChatPanel/index.d.ts +6 -0
- package/dist/esm/types/ui/Chatify.d.ts +45 -23
- package/dist/esm/types/ui/CreateChatPanel/CreateChatForm.d.ts +11 -0
- package/dist/esm/types/ui/CreateChatPanel/CreateChatMemberInput.d.ts +5 -0
- package/dist/esm/types/ui/CreateChatPanel/CreateChatNameInput.d.ts +5 -0
- package/dist/esm/types/ui/CreateChatPanel/CreateChatPanel.d.ts +2 -0
- package/dist/esm/types/ui/CreateChatPanel/index.d.ts +4 -0
- package/dist/esm/types/ui/Icon.d.ts +13 -4
- package/dist/esm/types/ui/InputBox/InputBox.d.ts +2 -0
- package/dist/esm/types/ui/InputBox/InputFilesBox.d.ts +2 -0
- package/dist/esm/types/ui/InputBox/InputSubmitButtonBox.d.ts +5 -0
- package/dist/esm/types/ui/InputBox/InputTextBox.d.ts +7 -0
- package/dist/esm/types/ui/InputBox/index.d.ts +4 -0
- package/dist/esm/types/ui/Layout/Aside.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Body.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Footer.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Header.d.ts +2 -0
- package/dist/esm/types/ui/Layout/Main.d.ts +2 -0
- package/dist/esm/types/ui/Layout/index.d.ts +5 -0
- package/dist/esm/types/ui/Message/MessageAuthor.d.ts +3 -0
- package/dist/esm/types/ui/Message/MessageBox.d.ts +6 -0
- package/dist/esm/types/ui/Message/MessageContent.d.ts +3 -0
- package/dist/esm/types/ui/Message/MessageInfoBox.d.ts +3 -0
- package/dist/esm/types/ui/Message/MessageRow.d.ts +6 -0
- package/dist/esm/types/ui/Message/MessageText.d.ts +3 -0
- package/dist/esm/types/ui/Message/index.d.ts +6 -0
- package/dist/esm/types/ui/MessageReadObserver.d.ts +6 -0
- package/dist/esm/types/ui/Next.d.ts +4 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageBox.d.ts +7 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageContent.d.ts +3 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageInfoBox.d.ts +3 -0
- package/dist/esm/types/ui/SendingMessage/SendingMessageText.d.ts +3 -0
- package/dist/esm/types/ui/SendingMessage/index.d.ts +4 -0
- package/dist/esm/types/ui/SystemMessage/SystemMessageBox.d.ts +6 -0
- package/dist/esm/types/ui/SystemMessage/SystemMessageRow.d.ts +9 -0
- package/dist/esm/types/ui/SystemMessage/index.d.ts +2 -0
- package/dist/esm/types/{util → ui}/customize.d.ts +2 -3
- package/dist/esm/types/ui/index.d.ts +6 -6
- package/dist/esm/types/ui/localizer.d.ts +5 -0
- package/dist/esm/types/util/index.d.ts +0 -1
- package/dist/index.d.ts +353 -142
- package/package.json +3 -1
- package/src/core/action.tsx +319 -233
- package/src/core/client.ts +6 -0
- package/src/core/index.ts +11 -8
- package/src/core/models.tsx +11 -4
- package/src/core/reducer.tsx +2 -1
- package/src/core/state.ts +68 -14
- package/src/core/useAddChatMutation.tsx +22 -0
- package/src/core/useAddMemberMutation.tsx +25 -0
- package/src/core/useFetchNextMutation.tsx +28 -0
- package/src/core/useGetAccountsQuery.tsx +33 -0
- package/src/core/useGetChatListQuery.tsx +33 -0
- package/src/core/useGetChatQuery.tsx +34 -0
- package/src/core/useGetMessagesQuery.tsx +35 -0
- package/src/core/useReadMonitor.tsx +8 -7
- package/src/core/useRemoveMemberMutation.tsx +23 -0
- package/src/core/useSendMutation.tsx +24 -0
- package/src/core/useSignalRMonitor.tsx +19 -5
- package/src/core/useUpdateChatNameMutation.tsx +23 -0
- package/src/{ui/styles → styles}/aside.scss +1 -1
- package/src/styles/chat.scss +222 -0
- package/src/styles/index.scss +79 -0
- package/src/styles/settings.scss +5 -0
- package/src/ui/AddChatButton.tsx +4 -8
- package/src/ui/Avatar.tsx +1 -1
- package/src/ui/ChatList/ChatList.tsx +42 -0
- package/src/ui/ChatList/ChatListItemBox.tsx +22 -0
- package/src/ui/ChatList/ChatListItemLastMessage.tsx +13 -0
- package/src/ui/ChatList/ChatListItemLastMessageAuthor.tsx +20 -0
- package/src/ui/ChatList/ChatListItemLastMessageContent.tsx +21 -0
- package/src/ui/ChatList/ChatListItemName.tsx +13 -0
- package/src/ui/ChatList/ChatListItemUnreadCount.tsx +12 -0
- package/src/ui/ChatList/index.ts +7 -0
- package/src/ui/ChatName.tsx +3 -8
- package/src/ui/ChatPanel/ChatBody.tsx +44 -0
- package/src/ui/ChatPanel/ChatHeader.tsx +33 -0
- package/src/ui/{ChatHeaderMembers.tsx → ChatPanel/ChatHeaderMembers.tsx} +5 -9
- package/src/ui/ChatPanel/ChatHeaderName.tsx +67 -0
- package/src/ui/ChatPanel/ChatMembersButton.tsx +21 -0
- package/src/ui/ChatPanel/ChatMembersPanel.tsx +117 -0
- package/src/ui/ChatPanel/ChatPanel.tsx +27 -0
- package/src/ui/ChatPanel/index.ts +6 -0
- package/src/ui/Chatify.tsx +78 -36
- package/src/ui/CreateChatPanel/CreateChatForm.tsx +36 -0
- package/src/ui/CreateChatPanel/CreateChatMemberInput.tsx +66 -0
- package/src/ui/CreateChatPanel/CreateChatNameInput.tsx +25 -0
- package/src/ui/CreateChatPanel/CreateChatPanel.tsx +33 -0
- package/src/ui/CreateChatPanel/index.ts +4 -0
- package/src/ui/Icon.tsx +18 -6
- package/src/ui/InputBox/InputBox.tsx +38 -0
- package/src/ui/InputBox/InputFilesBox.tsx +9 -0
- package/src/ui/InputBox/InputSubmitButtonBox.tsx +17 -0
- package/src/ui/InputBox/InputTextBox.tsx +50 -0
- package/src/ui/InputBox/index.ts +4 -0
- package/src/ui/Layout/Aside.tsx +10 -0
- package/src/ui/Layout/Body.tsx +10 -0
- package/src/ui/Layout/Footer.tsx +3 -0
- package/src/ui/Layout/Header.tsx +10 -0
- package/src/ui/Layout/Main.tsx +15 -0
- package/src/ui/Layout/index.ts +5 -0
- package/src/ui/Message/MessageAuthor.tsx +13 -0
- package/src/ui/Message/MessageBox.tsx +20 -0
- package/src/ui/Message/MessageContent.tsx +13 -0
- package/src/ui/Message/MessageInfoBox.tsx +25 -0
- package/src/ui/Message/MessageRow.tsx +24 -0
- package/src/ui/Message/MessageText.tsx +7 -0
- package/src/ui/Message/index.ts +6 -0
- package/src/ui/MessageReadObserver.tsx +45 -0
- package/src/ui/{LoadMore.tsx → Next.tsx} +16 -8
- package/src/ui/SendingMessage/SendingMessageBox.tsx +16 -0
- package/src/ui/SendingMessage/SendingMessageContent.tsx +13 -0
- package/src/ui/SendingMessage/SendingMessageInfoBox.tsx +13 -0
- package/src/ui/SendingMessage/SendingMessageText.tsx +7 -0
- package/src/ui/SendingMessage/index.ts +4 -0
- package/src/ui/SystemMessage/SystemMessageBox.tsx +20 -0
- package/src/ui/SystemMessage/SystemMessageRow.tsx +43 -0
- package/src/ui/SystemMessage/index.ts +2 -0
- package/src/{util → ui}/customize.tsx +5 -5
- package/src/ui/index.ts +6 -6
- package/src/ui/localizer.tsx +12 -0
- package/src/util/index.ts +0 -1
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types/ChatifyContext.d.ts +0 -11
- package/dist/cjs/types/core/action.d.ts +0 -76
- package/dist/cjs/types/core/client.d.ts +0 -35
- package/dist/cjs/types/core/index.d.ts +0 -14
- package/dist/cjs/types/core/models.d.ts +0 -64
- package/dist/cjs/types/core/reducer.d.ts +0 -11
- package/dist/cjs/types/core/state.d.ts +0 -25
- package/dist/cjs/types/core/useAccounts.d.ts +0 -1
- package/dist/cjs/types/core/useAddChat.d.ts +0 -2
- package/dist/cjs/types/core/useAddMember.d.ts +0 -2
- package/dist/cjs/types/core/useAddMessage.d.ts +0 -5
- package/dist/cjs/types/core/useChatList.d.ts +0 -1
- package/dist/cjs/types/core/useLoadMore.d.ts +0 -3
- package/dist/cjs/types/core/useMessages.d.ts +0 -15
- package/dist/cjs/types/core/useMutation.d.ts +0 -12
- package/dist/cjs/types/core/useQuery.d.ts +0 -7
- package/dist/cjs/types/core/useReadMonitor.d.ts +0 -1
- package/dist/cjs/types/core/useRemoveMember.d.ts +0 -2
- package/dist/cjs/types/core/useSignalRMonitor.d.ts +0 -2
- package/dist/cjs/types/index.d.ts +0 -3
- package/dist/cjs/types/ui/AddChat.d.ts +0 -1
- package/dist/cjs/types/ui/AddChatButton.d.ts +0 -2
- package/dist/cjs/types/ui/Aside.d.ts +0 -1
- package/dist/cjs/types/ui/Avatar.d.ts +0 -6
- package/dist/cjs/types/ui/Chat.d.ts +0 -4
- package/dist/cjs/types/ui/ChatBody.d.ts +0 -4
- package/dist/cjs/types/ui/ChatHeader.d.ts +0 -4
- package/dist/cjs/types/ui/ChatHeaderMembers.d.ts +0 -5
- package/dist/cjs/types/ui/ChatHeaderSettingsButton.d.ts +0 -5
- package/dist/cjs/types/ui/ChatListItem.d.ts +0 -11
- package/dist/cjs/types/ui/ChatName.d.ts +0 -5
- package/dist/cjs/types/ui/ChatSettings.d.ts +0 -1
- package/dist/cjs/types/ui/Chatify.d.ts +0 -49
- package/dist/cjs/types/ui/Footer.d.ts +0 -2
- package/dist/cjs/types/ui/Header.d.ts +0 -2
- package/dist/cjs/types/ui/Icon.d.ts +0 -7
- package/dist/cjs/types/ui/InputForm.d.ts +0 -1
- package/dist/cjs/types/ui/LoadMore.d.ts +0 -4
- package/dist/cjs/types/ui/Main.d.ts +0 -1
- package/dist/cjs/types/ui/Message.d.ts +0 -18
- package/dist/cjs/types/ui/MessageSkeleton.d.ts +0 -4
- package/dist/cjs/types/ui/SendingMessage.d.ts +0 -10
- package/dist/cjs/types/ui/SystemMessage.d.ts +0 -8
- package/dist/cjs/types/ui/index.d.ts +0 -11
- package/dist/cjs/types/ui/localizer.d.ts +0 -32
- package/dist/cjs/types/util/customize.d.ts +0 -12
- package/dist/cjs/types/util/index.d.ts +0 -3
- package/dist/cjs/types/util/uniqBy.d.ts +0 -1
- package/dist/cjs/types/util/uniqId.d.ts +0 -1
- package/dist/esm/types/core/useAccounts.d.ts +0 -1
- package/dist/esm/types/core/useAddChat.d.ts +0 -2
- package/dist/esm/types/core/useAddMember.d.ts +0 -2
- package/dist/esm/types/core/useAddMessage.d.ts +0 -5
- package/dist/esm/types/core/useChat.d.ts +0 -3
- package/dist/esm/types/core/useChatList.d.ts +0 -1
- package/dist/esm/types/core/useLoadMore.d.ts +0 -3
- package/dist/esm/types/core/useMessages.d.ts +0 -15
- package/dist/esm/types/core/useMutation.d.ts +0 -12
- package/dist/esm/types/core/useQuery.d.ts +0 -7
- package/dist/esm/types/core/useRemoveMember.d.ts +0 -2
- package/dist/esm/types/ui/AddChat.d.ts +0 -1
- package/dist/esm/types/ui/Aside.d.ts +0 -1
- package/dist/esm/types/ui/Chat.d.ts +0 -4
- package/dist/esm/types/ui/ChatBody.d.ts +0 -4
- package/dist/esm/types/ui/ChatHeader.d.ts +0 -4
- package/dist/esm/types/ui/ChatHeaderMembers.d.ts +0 -5
- package/dist/esm/types/ui/ChatHeaderSettingsButton.d.ts +0 -5
- package/dist/esm/types/ui/ChatListItem.d.ts +0 -11
- package/dist/esm/types/ui/ChatSettings.d.ts +0 -1
- package/dist/esm/types/ui/Footer.d.ts +0 -2
- package/dist/esm/types/ui/Header.d.ts +0 -2
- package/dist/esm/types/ui/InputForm.d.ts +0 -1
- package/dist/esm/types/ui/LoadMore.d.ts +0 -4
- package/dist/esm/types/ui/Main.d.ts +0 -1
- package/dist/esm/types/ui/Message.d.ts +0 -18
- package/dist/esm/types/ui/SendingMessage.d.ts +0 -10
- package/dist/esm/types/ui/SystemMessage.d.ts +0 -8
- package/src/core/useAccounts.tsx +0 -11
- package/src/core/useAddChat.tsx +0 -12
- package/src/core/useAddMember.tsx +0 -12
- package/src/core/useAddMessage.tsx +0 -40
- package/src/core/useChat.tsx +0 -12
- package/src/core/useChatList.tsx +0 -10
- package/src/core/useLoadMore.tsx +0 -42
- package/src/core/useMessages.tsx +0 -23
- package/src/core/useMutation.tsx +0 -48
- package/src/core/useQuery.tsx +0 -45
- package/src/core/useRemoveMember.tsx +0 -12
- package/src/ui/AddChat.tsx +0 -55
- package/src/ui/Aside.tsx +0 -41
- package/src/ui/Chat.tsx +0 -26
- package/src/ui/ChatBody.tsx +0 -43
- package/src/ui/ChatHeader.tsx +0 -33
- package/src/ui/ChatHeaderSettingsButton.tsx +0 -26
- package/src/ui/ChatListItem.tsx +0 -101
- package/src/ui/ChatSettings.tsx +0 -59
- package/src/ui/Footer.tsx +0 -7
- package/src/ui/Header.tsx +0 -14
- package/src/ui/InputForm.tsx +0 -51
- package/src/ui/Main.tsx +0 -16
- package/src/ui/Message.tsx +0 -118
- package/src/ui/SendingMessage.tsx +0 -50
- package/src/ui/SystemMessage.tsx +0 -32
- package/src/ui/styles/index.scss +0 -248
- /package/src/{ui/styles → styles}/keyframes.scss +0 -0
- /package/src/{ui/styles → styles}/mixins.scss +0 -0
- /package/src/{ui/styles → styles}/variables.scss +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@webinex/chatify",
|
|
3
3
|
"description": "Webinex Wispo",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "1.0.0-
|
|
5
|
+
"version": "1.0.0-rc3",
|
|
6
6
|
"author": "Webinex Dev",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/cjs/index.js",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"dayjs": "^1.11.7",
|
|
47
47
|
"eslint": "^8.38.0",
|
|
48
48
|
"eslint-config-react-app": "^7.0.1",
|
|
49
|
+
"immer": "^10.0.3",
|
|
49
50
|
"is-hotkey": "^0.2.0",
|
|
50
51
|
"parcel": "^2.10.3",
|
|
51
52
|
"postcss": "^8.4.21",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
"axios": ">=1",
|
|
79
80
|
"classnames": ">=2",
|
|
80
81
|
"dayjs": ">=1.8",
|
|
82
|
+
"immer": ">=8",
|
|
81
83
|
"is-hotkey": ">=0",
|
|
82
84
|
"react": ">=16",
|
|
83
85
|
"react-dom": ">=16",
|
package/src/core/action.tsx
CHANGED
|
@@ -1,217 +1,232 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Account, ChatListItem, Message, ReadEvent } from './models';
|
|
3
|
-
import { MessageState } from './useMessages';
|
|
4
|
-
|
|
5
|
-
function updateQuery<TData>(
|
|
6
|
-
state: State,
|
|
7
|
-
key: string,
|
|
8
|
-
mutation: (queryState: QueryState<TData> | undefined) => QueryState<TData> | undefined,
|
|
9
|
-
) {
|
|
10
|
-
state = {
|
|
11
|
-
...state,
|
|
12
|
-
query: {
|
|
13
|
-
...state.query,
|
|
14
|
-
},
|
|
15
|
-
};
|
|
1
|
+
import type { State } from './state';
|
|
2
|
+
import { Account, Chat, ChatListItem, Message, ReadEvent, File } from './models';
|
|
16
3
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
state
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
export const ACTIONS = {
|
|
5
|
+
update: (state: State, { mutation }: { mutation: (state: State) => State }) => {
|
|
6
|
+
mutation(state);
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
messages_fetch: (state: State, { chatId }: { chatId: string }) => {
|
|
10
|
+
state.query.messages[chatId] = {
|
|
11
|
+
...state.query.messages[chatId],
|
|
12
|
+
uninitialized: false,
|
|
13
|
+
isFetching: true,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
messages_fulfilled: (
|
|
18
|
+
state: State,
|
|
19
|
+
{ chatId, messages, hasMore }: { chatId: string; messages: Message[]; hasMore: boolean },
|
|
20
|
+
) => {
|
|
21
|
+
const qState = state.query.messages[chatId];
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
return state;
|
|
41
|
-
}
|
|
23
|
+
qState.error = undefined;
|
|
24
|
+
qState.isFetching = false;
|
|
25
|
+
qState.data = messages.map((x) => ({ type: 'message', ...x }));
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
if (hasMore) {
|
|
28
|
+
qState.data!.push({ type: 'next' });
|
|
29
|
+
}
|
|
46
30
|
},
|
|
47
31
|
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
messages_rejected: (state: State, { chatId, error }: { chatId: string; error: any }) => {
|
|
33
|
+
const qState = state.query.messages[chatId];
|
|
34
|
+
qState.error = error;
|
|
35
|
+
qState.isFetching = false;
|
|
50
36
|
},
|
|
51
37
|
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
fetchNext_fetch: (state: State, { chatId }: { chatId: string }) => {
|
|
39
|
+
state.mutation.fetchNext = { isFetching: true };
|
|
54
40
|
},
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
fetchNext_fulfilled: (
|
|
43
|
+
state: State,
|
|
44
|
+
{ chatId, messages, hasMore }: { chatId: string; messages: Message[]; hasMore: boolean },
|
|
45
|
+
) => {
|
|
46
|
+
state.mutation.fetchNext = { isFetching: false, error: undefined };
|
|
47
|
+
state.query.messages[chatId].data = state.query.messages[chatId].data!.filter((x) => x.type !== 'next');
|
|
48
|
+
state.query.messages[chatId].data!.push(...messages.map((x) => ({ type: 'message' as const, ...x })));
|
|
49
|
+
|
|
50
|
+
if (hasMore) state.query.messages[chatId].data!.push({ type: 'next' });
|
|
58
51
|
},
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
fetchNext_rejected: (state: State, { chatId, error }: { chatId: string; error: any }) => {
|
|
54
|
+
state.mutation.fetchNext = { isFetching: false, error };
|
|
62
55
|
},
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
chatList_fetch: (state: State) => {
|
|
58
|
+
state.query.chatList.isFetching = true;
|
|
59
|
+
state.query.chatList.uninitialized = false;
|
|
66
60
|
},
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
chatList_fulfilled: (state: State, { chats }: { chats: ChatListItem[] }) => {
|
|
63
|
+
chats = chats.sort((a, b) => -a.message.id.substring(47).localeCompare(b.message.id.substring(47)));
|
|
64
|
+
|
|
65
|
+
state.query.chatList.isFetching = false;
|
|
66
|
+
state.query.chatList.error = undefined;
|
|
67
|
+
state.query.chatList.data = chats;
|
|
68
|
+
|
|
69
|
+
if (state.ui.chatId === undefined && chats.length > 0) {
|
|
70
|
+
state.ui.view = 'chat';
|
|
71
|
+
state.ui.chatId = chats[0].id;
|
|
72
|
+
}
|
|
70
73
|
},
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
chatList_rejected: (state: State, { error }: { error: any }) => {
|
|
76
|
+
state.query.chatList.isFetching = false;
|
|
77
|
+
state.query.chatList.error = error;
|
|
74
78
|
},
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
removeMember_fetch: (state: State) => {
|
|
81
|
+
state.mutation.removeMember = { isFetching: true };
|
|
78
82
|
},
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
removeMember_fulfilled: (state: State) => {
|
|
85
|
+
state.mutation.removeMember = { isFetching: false, error: undefined };
|
|
82
86
|
},
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
state:
|
|
86
|
-
|
|
87
|
-
): State => {
|
|
88
|
-
if (state.query['messages.' + message.chatId]?.data !== undefined) {
|
|
89
|
-
state = {
|
|
90
|
-
...state,
|
|
91
|
-
query: {
|
|
92
|
-
...state.query,
|
|
93
|
-
['messages.' + message.chatId]: {
|
|
94
|
-
...state.query['messages.' + message.chatId],
|
|
95
|
-
data: [{ type: 'message', ...message }, ...state.query['messages.' + message.chatId].data].filter(
|
|
96
|
-
(x: MessageState) => x.type !== 'sending' || x.requestId !== requestId,
|
|
97
|
-
),
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
88
|
+
removeMember_rejected: (state: State, { error }: { error: any }) => {
|
|
89
|
+
state.mutation.removeMember = { isFetching: false, error };
|
|
90
|
+
},
|
|
102
91
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
query: {
|
|
107
|
-
...state.query,
|
|
108
|
-
'chat-list': {
|
|
109
|
-
...state.query['chat-list'],
|
|
110
|
-
data: state.query['chat-list'].data.map((x: ChatListItem) =>
|
|
111
|
-
x.id === message.chatId
|
|
112
|
-
? { ...x, message, unreadCount: message.read ? x.unreadCount : x.unreadCount + 1 }
|
|
113
|
-
: x,
|
|
114
|
-
),
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
}
|
|
92
|
+
addMember_fetch: (state: State) => {
|
|
93
|
+
state.mutation.addMember = { isFetching: true };
|
|
94
|
+
},
|
|
119
95
|
|
|
120
|
-
|
|
96
|
+
addMember_fulfilled: (state: State) => {
|
|
97
|
+
state.mutation.addMember = { isFetching: false, error: undefined };
|
|
121
98
|
},
|
|
122
99
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
100
|
+
addMember_rejected: (state: State, { error }: { error: any }) => {
|
|
101
|
+
state.mutation.addMember = { isFetching: false, error };
|
|
102
|
+
},
|
|
127
103
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
query: {
|
|
131
|
-
...state.query,
|
|
132
|
-
'chat-list': {
|
|
133
|
-
...state.query['chat-list'],
|
|
134
|
-
data: [chat, ...state.query['chat-list'].data!],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
};
|
|
104
|
+
updateChatName_fetch: (state: State) => {
|
|
105
|
+
state.mutation.updateChatName = { isFetching: true };
|
|
138
106
|
},
|
|
139
107
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
...state,
|
|
143
|
-
read: {
|
|
144
|
-
...state.read,
|
|
145
|
-
queued: [...state.read.queued, id],
|
|
146
|
-
timestamp,
|
|
147
|
-
},
|
|
148
|
-
};
|
|
108
|
+
updateChatName_fulfilled: (state: State) => {
|
|
109
|
+
state.mutation.updateChatName = { isFetching: false, error: undefined };
|
|
149
110
|
},
|
|
150
111
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
...state,
|
|
154
|
-
read: {
|
|
155
|
-
...state.read,
|
|
156
|
-
queued: state.read.queued.filter((x) => !ids.includes(x)),
|
|
157
|
-
sent: [...state.read.sent, ...ids],
|
|
158
|
-
},
|
|
159
|
-
};
|
|
112
|
+
updateChatName_rejected: (state: State, { error }: { error: any }) => {
|
|
113
|
+
state.mutation.updateChatName = { isFetching: false, error };
|
|
160
114
|
},
|
|
161
115
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
...state,
|
|
165
|
-
read: {
|
|
166
|
-
...state.read,
|
|
167
|
-
queued: [...state.read.queued, ...ids],
|
|
168
|
-
sent: state.read.sent.filter((x) => !ids.includes(x)),
|
|
169
|
-
timestamp,
|
|
170
|
-
},
|
|
171
|
-
};
|
|
116
|
+
addChat_fetch: (state: State) => {
|
|
117
|
+
state.mutation.addChat = { isFetching: true };
|
|
172
118
|
},
|
|
173
119
|
|
|
174
|
-
|
|
175
|
-
|
|
120
|
+
addChat_fulfilled: (state: State) => {
|
|
121
|
+
state.mutation.addChat = { isFetching: false, error: undefined };
|
|
122
|
+
},
|
|
176
123
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
...state.query,
|
|
181
|
-
},
|
|
182
|
-
read: {
|
|
183
|
-
...state.read,
|
|
184
|
-
sent: state.read.sent.filter((x) => !ids.includes(x)),
|
|
185
|
-
},
|
|
186
|
-
};
|
|
124
|
+
addChat_rejected: (state: State, { error }: { error: any }) => {
|
|
125
|
+
state.mutation.addChat = { isFetching: false, error };
|
|
126
|
+
},
|
|
187
127
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
state.query[key] = { ...state.query[key] };
|
|
192
|
-
const queryState: QueryState<MessageState[]> = state.query[key];
|
|
128
|
+
accounts_fetch: (state: State) => {
|
|
129
|
+
state.query.accounts = { isFetching: true, uninitialized: false };
|
|
130
|
+
},
|
|
193
131
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
132
|
+
accounts_fulfilled: (state: State, { accounts }: { accounts: Account[] }) => {
|
|
133
|
+
state.query.accounts.data = accounts;
|
|
134
|
+
state.query.accounts.isFetching = false;
|
|
135
|
+
state.query.accounts.error = undefined;
|
|
136
|
+
},
|
|
198
137
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
138
|
+
accounts_rejected: (state: State, { error }: { error: any }) => {
|
|
139
|
+
state.query.accounts.isFetching = false;
|
|
140
|
+
state.query.accounts.error = error;
|
|
141
|
+
},
|
|
202
142
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
143
|
+
chat_open: (state: State, { chatId }: { chatId: string }) => {
|
|
144
|
+
state.ui.chatId = chatId;
|
|
145
|
+
state.ui.view = 'chat';
|
|
146
|
+
},
|
|
208
147
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
148
|
+
new_chat_open: (state: State) => {
|
|
149
|
+
state.ui.chatId = undefined;
|
|
150
|
+
state.ui.view = 'new-chat';
|
|
151
|
+
},
|
|
213
152
|
|
|
214
|
-
|
|
153
|
+
toggle_members_view: (state: State) => {
|
|
154
|
+
state.ui.showMembers = !state.ui.showMembers;
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
message_received: (
|
|
158
|
+
state: State,
|
|
159
|
+
{ message, requestId, me }: { message: Message; requestId: string; me: string },
|
|
160
|
+
) => {
|
|
161
|
+
const messagesState = state.query.messages[message.chatId];
|
|
162
|
+
|
|
163
|
+
if (messagesState?.data) {
|
|
164
|
+
messagesState.data.unshift({ type: 'message', ...message });
|
|
165
|
+
messagesState.data = messagesState.data.filter(
|
|
166
|
+
(x) => x.type !== 'sending' || x.requestId !== requestId,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const chatListItemState = state.query.chatList?.data?.find((x) => x.id === message.chatId);
|
|
171
|
+
|
|
172
|
+
if (chatListItemState) {
|
|
173
|
+
chatListItemState.message = message;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (chatListItemState && message.sentBy.id !== me) {
|
|
177
|
+
chatListItemState.totalUnreadCount++;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (chatListItemState && message.sentBy.id === me) {
|
|
181
|
+
chatListItemState.lastReadMessageId = message.id;
|
|
182
|
+
chatListItemState.totalUnreadCount = 0;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
chat_created: (state: State, { chat }: { chat: ChatListItem; requestId?: string }) => {
|
|
187
|
+
state.query.chatList?.data?.unshift(chat);
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
read: (state: State, { id, timestamp }: { id: string; timestamp: number }) => {
|
|
191
|
+
const queuedSameChat = state.queue.read.queued.filter((x) => x.substring(0, 36) === id.substring(0, 36));
|
|
192
|
+
|
|
193
|
+
if (queuedSameChat.some((x) => x.localeCompare(id) >= 0)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
state.queue.read.queued.filter((x) => queuedSameChat.includes(x));
|
|
198
|
+
state.queue.read.queued.push(id);
|
|
199
|
+
state.queue.read.timestamp = timestamp;
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
read_send: (state: State, { id }: { id: string }) => {
|
|
203
|
+
state.queue.read.queued = state.queue.read.queued.filter((x) => x !== id);
|
|
204
|
+
state.queue.read.processing.push(id);
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
read_reject: (state: State, { id, timestamp }: { id: string; timestamp: number }) => {
|
|
208
|
+
state.queue.read.queued.push(id);
|
|
209
|
+
state.queue.read.processing = state.queue.read.processing.filter((x) => x !== id);
|
|
210
|
+
state.queue.read.timestamp = timestamp;
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
read_received: (state: State, { events }: { events: ReadEvent[] }) => {
|
|
214
|
+
state.queue.read.processing = state.queue.read.processing.filter((item) => {
|
|
215
|
+
const event = events.find((x) => x.chatId === item.substring(0, 36));
|
|
216
|
+
return !event || event.newLastReadMessageId.localeCompare(item) >= 0;
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
for (const event of events) {
|
|
220
|
+
state.queue.read.processing = state.queue.read.processing.filter(
|
|
221
|
+
(x) => x.substring(0, 36) !== event.chatId || x.localeCompare(event.newLastReadMessageId) > 0,
|
|
222
|
+
);
|
|
223
|
+
const chatListItem = state.query.chatList.data?.find((x) => x.id === event.chatId);
|
|
224
|
+
|
|
225
|
+
if (chatListItem) {
|
|
226
|
+
chatListItem.lastReadMessageId = event.newLastReadMessageId;
|
|
227
|
+
chatListItem.totalUnreadCount = chatListItem.totalUnreadCount - event.readCount;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
215
230
|
},
|
|
216
231
|
|
|
217
232
|
member_added: (
|
|
@@ -222,49 +237,42 @@ export const ACTIONS = {
|
|
|
222
237
|
account,
|
|
223
238
|
me,
|
|
224
239
|
message,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (state.query['messages.' + chatId]?.data !== undefined) {
|
|
243
|
-
state.query['messages.' + chatId] = {
|
|
244
|
-
...state.query['messages.' + chatId],
|
|
245
|
-
data: [{ type: 'message', ...message }, ...state.query['messages.' + chatId].data],
|
|
246
|
-
};
|
|
240
|
+
withHistory,
|
|
241
|
+
}: {
|
|
242
|
+
chatId: string;
|
|
243
|
+
chatName: string;
|
|
244
|
+
account: Account;
|
|
245
|
+
me: string;
|
|
246
|
+
message: Message;
|
|
247
|
+
withHistory: boolean;
|
|
248
|
+
},
|
|
249
|
+
) => {
|
|
250
|
+
const { chats, messages, chatList } = state.query;
|
|
251
|
+
chats[chatId]?.data?.members.push(account);
|
|
252
|
+
const chatListItem = chatList?.data?.find((x) => x.id === chatId);
|
|
253
|
+
|
|
254
|
+
if (account.id !== me && chatListItem != null) {
|
|
255
|
+
chatListItem.message = message;
|
|
256
|
+
chatListItem.totalUnreadCount++;
|
|
247
257
|
}
|
|
248
258
|
|
|
249
|
-
|
|
250
|
-
state.query['chat-list'] = { ...state.query['chat-list'] };
|
|
251
|
-
state.query['chat-list'].data = state.query['chat-list'].data.map((x: ChatListItem) =>
|
|
252
|
-
x.id === chatId ? { ...x, message: { ...message } } : x,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
259
|
+
messages[chatId]?.data?.unshift({ type: 'message', ...message });
|
|
255
260
|
|
|
256
|
-
if (account.id === me &&
|
|
257
|
-
|
|
261
|
+
if (account.id === me && chatList.data !== undefined && !chatListItem) {
|
|
262
|
+
chatList.data.unshift({
|
|
258
263
|
id: chatId,
|
|
259
264
|
name: chatName,
|
|
260
|
-
message
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
message,
|
|
266
|
+
totalUnreadCount: 1,
|
|
267
|
+
active: true,
|
|
268
|
+
lastReadMessageId: null,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (account.id === me && chatListItem) {
|
|
273
|
+
chatListItem.active = true;
|
|
274
|
+
chatListItem.message = message;
|
|
275
|
+
chatListItem.totalUnreadCount++;
|
|
268
276
|
}
|
|
269
277
|
|
|
270
278
|
return state;
|
|
@@ -277,37 +285,115 @@ export const ACTIONS = {
|
|
|
277
285
|
accountId,
|
|
278
286
|
deleteHistory,
|
|
279
287
|
me,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
...state.query,
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
+
message,
|
|
289
|
+
}: { chatId: string; accountId: string; deleteHistory: boolean; me: string; message: Message },
|
|
290
|
+
) => {
|
|
291
|
+
const { chats, chatList } = state.query;
|
|
292
|
+
const chat = chats[chatId];
|
|
288
293
|
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
...state.query['chat.' + chatId],
|
|
292
|
-
data: { ...state.query['chat.' + chatId].data },
|
|
293
|
-
};
|
|
294
|
-
state.query['chat.' + chatId].data.members = state.query['chat.' + chatId].data.members.filter(
|
|
295
|
-
(x: Account) => x.id !== accountId,
|
|
296
|
-
);
|
|
294
|
+
if (chat?.data) {
|
|
295
|
+
chat.data.members = chat.data.members.filter((x) => x.id !== accountId);
|
|
297
296
|
}
|
|
298
297
|
|
|
299
|
-
if (accountId === me &&
|
|
300
|
-
state.query
|
|
301
|
-
state.query['chat-list'].data = state.query['chat-list'].data.filter(
|
|
302
|
-
(x: ChatListItem) => x.id !== chatId,
|
|
303
|
-
);
|
|
298
|
+
if (accountId === me && state.query.chats[chatId].data) {
|
|
299
|
+
delete state.query.chats[chatId];
|
|
304
300
|
}
|
|
305
301
|
|
|
306
|
-
if (accountId === me && deleteHistory &&
|
|
307
|
-
|
|
302
|
+
if (accountId === me && deleteHistory && chatList?.data) {
|
|
303
|
+
chatList.data = chatList.data.filter((x) => x.id !== chatId);
|
|
304
|
+
|
|
305
|
+
if (state.ui.chatId === chatId) {
|
|
306
|
+
state.ui.chatId = chatList.data.at(0)?.id;
|
|
307
|
+
}
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
if (accountId === me && !deleteHistory && chatList?.data) {
|
|
311
|
+
const listItem = chatList.data.find((x) => x.id === chatId)!;
|
|
312
|
+
listItem.active = false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if ((accountId !== me || !deleteHistory) && state.query.messages[chatId].data) {
|
|
316
|
+
state.query.messages[chatId].data!.unshift({ ...message, type: 'message' });
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if ((accountId !== me || !deleteHistory) && state.query.chatList.data) {
|
|
320
|
+
const listItem = state.query.chatList.data.find((x) => x.id === chatId)!;
|
|
321
|
+
listItem.message = message;
|
|
322
|
+
listItem.totalUnreadCount++;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (accountId === me && deleteHistory && state.query.messages[chatId].data) {
|
|
326
|
+
delete state.query.messages[chatId];
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
chat_fetch: (state: State, { chatId }: { chatId: string }) => {
|
|
331
|
+
state.query.chats[chatId] = { isFetching: true, uninitialized: false, data: undefined, error: undefined };
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
chat_fulfilled: (state: State, { chat }: { chat: Chat }) => {
|
|
335
|
+
const chatState = state.query.chats[chat.id];
|
|
336
|
+
chatState.isFetching = false;
|
|
337
|
+
chatState.error = undefined;
|
|
338
|
+
chatState.data = chat;
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
chat_rejected: (state: State, { chatId, error }: { chatId: string; error: any }) => {
|
|
342
|
+
const chatState = state.query.chats[chatId];
|
|
343
|
+
chatState.isFetching = false;
|
|
344
|
+
chatState.error = error;
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
send_fetch: (
|
|
348
|
+
state: State,
|
|
349
|
+
{
|
|
350
|
+
chatId,
|
|
351
|
+
text,
|
|
352
|
+
files,
|
|
353
|
+
requestId,
|
|
354
|
+
}: {
|
|
355
|
+
chatId: string;
|
|
356
|
+
text: string;
|
|
357
|
+
files: File[];
|
|
358
|
+
requestId: string;
|
|
359
|
+
},
|
|
360
|
+
) => {
|
|
361
|
+
state.mutation.send = { isFetching: true, error: undefined };
|
|
362
|
+
state.query.messages[chatId].data?.push({ type: 'sending', text, files, requestId });
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
send_fulfilled: (state: State, { chatId, requestId }: { chatId: string; requestId: string }) => {
|
|
366
|
+
state.mutation.send = { isFetching: false, error: undefined };
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
send_rejected: (
|
|
370
|
+
state: State,
|
|
371
|
+
{ chatId, requestId, error }: { chatId: string; requestId: string; error: any },
|
|
372
|
+
) => {
|
|
373
|
+
state.mutation.send = { isFetching: false, error };
|
|
374
|
+
state.query.messages[chatId].data = state.query.messages[chatId].data?.filter(
|
|
375
|
+
(x) => x.type !== 'sending' || x.requestId !== requestId,
|
|
376
|
+
);
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
chatNameChanged_received: (
|
|
380
|
+
state: State,
|
|
381
|
+
{ chatId, newName, message }: { chatId: string; newName: string; message: Message },
|
|
382
|
+
) => {
|
|
383
|
+
if (state.query.chatList.data) {
|
|
384
|
+
const chatListItem = state.query.chatList.data.find((x) => x.id === chatId);
|
|
385
|
+
chatListItem!.name = newName;
|
|
386
|
+
chatListItem!.message = message;
|
|
387
|
+
chatListItem!.totalUnreadCount++;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (state.query.chats[chatId].data) {
|
|
391
|
+
state.query.chats[chatId].data!.name = newName;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (state.query.messages[chatId].data) {
|
|
395
|
+
state.query.messages[chatId].data!.unshift({ type: 'message', ...message });
|
|
396
|
+
}
|
|
311
397
|
},
|
|
312
398
|
};
|
|
313
399
|
|
package/src/core/client.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ReadRequest,
|
|
11
11
|
RemoveMemberRequest,
|
|
12
12
|
SendMessageRequest,
|
|
13
|
+
UpdateChatNameRequest,
|
|
13
14
|
} from './models';
|
|
14
15
|
|
|
15
16
|
export interface ChatifySignalRConfig {
|
|
@@ -34,6 +35,7 @@ const METHODS = [
|
|
|
34
35
|
'chatify://read',
|
|
35
36
|
'chatify://member-added',
|
|
36
37
|
'chatify://member-removed',
|
|
38
|
+
'chatify://chat-name-changed',
|
|
37
39
|
] as const;
|
|
38
40
|
|
|
39
41
|
export class ChatifyClient {
|
|
@@ -131,6 +133,10 @@ export class ChatifyClient {
|
|
|
131
133
|
await this.axios.delete(`chat/${request.chatId}/member`, { data: request });
|
|
132
134
|
};
|
|
133
135
|
|
|
136
|
+
public updateChatName = async (request: UpdateChatNameRequest) => {
|
|
137
|
+
await this.axios.put(`chat/${request.id}/name`, request);
|
|
138
|
+
};
|
|
139
|
+
|
|
134
140
|
public addMember = async (request: AddMemberRequest) => {
|
|
135
141
|
await this.axios.post(`chat/${request.chatId}/member`, request);
|
|
136
142
|
};
|