@webinex/chatify 2.0.1-alpha1 → 2.0.2-alpha2
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 +111 -12
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/core/api/api.d.ts +10784 -232
- package/dist/esm/types/core/api/baseApi.d.ts +1 -1
- package/dist/esm/types/ui/Conversation/Conversation.d.ts +2 -0
- package/dist/esm/types/ui/Conversation/ConversationContext.d.ts +2 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputBoxFile.d.ts +8 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +8 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputFilesBox.d.ts +11 -1
- package/dist/esm/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +2 -0
- package/dist/esm/types/ui/Conversation/InputBox/InputTextBox.d.ts +1 -0
- package/dist/esm/types/ui/Conversation/InputBox/index.d.ts +8 -1
- package/dist/esm/types/ui/Conversation/Message/MessageFile.d.ts +6 -0
- package/dist/esm/types/ui/Conversation/Message/MessageFileList.d.ts +3 -0
- package/dist/esm/types/ui/Conversation/Message/index.d.ts +6 -0
- package/dist/esm/types/ui/common/Icon.d.ts +2 -0
- package/dist/esm/types/ui/customize.d.ts +2 -2
- package/dist/esm/types/ui/localizer.d.ts +5 -0
- package/dist/esm/types/ui/useFormatter.d.ts +3 -0
- package/dist/index.d.ts +10835 -239
- package/package.json +94 -93
- package/src/core/api/api.ts +643 -642
- package/src/core/api/baseApi.ts +38 -38
- package/src/core/api/index.ts +1 -1
- package/src/core/client.ts +280 -280
- package/src/core/constants.ts +1 -1
- package/src/core/debounce.ts +90 -90
- package/src/core/index.ts +4 -4
- package/src/core/types.tsx +152 -152
- package/src/index.ts +2 -2
- package/src/styles/aside.scss +162 -161
- package/src/styles/chat.scss +209 -208
- package/src/styles/index.scss +153 -110
- package/src/styles/input.scss +147 -74
- package/src/styles/keyframes.scss +14 -14
- package/src/styles/members.scss +13 -13
- package/src/styles/mixins.scss +25 -20
- package/src/styles/variables.scss +13 -10
- package/src/ui/Chat/ChatContext.tsx +30 -30
- package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
- package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
- package/src/ui/Chat/ChatPanel.tsx +30 -30
- package/src/ui/Chat/ChatView.tsx +115 -115
- package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
- package/src/ui/Chat/Members/ChatMembersPanel.tsx +112 -112
- package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
- package/src/ui/Chat/Members/index.ts +13 -13
- package/src/ui/Chat/index.ts +6 -6
- package/src/ui/ChatGroup/ChatGroupContext.tsx +50 -50
- package/src/ui/ChatGroup/ChatGroupPanel.tsx +73 -73
- package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
- package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
- package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
- package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
- package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
- package/src/ui/ChatGroup/Create/index.ts +19 -19
- package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
- package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +10 -10
- package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
- package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
- package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +17 -17
- package/src/ui/ChatGroup/Layout/index.ts +19 -19
- package/src/ui/ChatGroup/List/ChatList.tsx +41 -41
- package/src/ui/ChatGroup/List/ChatListItemAvatar.tsx +22 -22
- package/src/ui/ChatGroup/List/ChatListItemBox.tsx +26 -26
- package/src/ui/ChatGroup/List/ChatListItemLastMessage.tsx +15 -15
- package/src/ui/ChatGroup/List/ChatListItemLastMessageAuthor.tsx +15 -15
- package/src/ui/ChatGroup/List/ChatListItemLastMessageContent.tsx +21 -21
- package/src/ui/ChatGroup/List/ChatListItemLastMessageSentAt.tsx +22 -22
- package/src/ui/ChatGroup/List/ChatListItemName.tsx +8 -8
- package/src/ui/ChatGroup/List/ChatListItemUnreadCount.tsx +12 -12
- package/src/ui/ChatGroup/List/index.ts +31 -31
- package/src/ui/ChatGroup/index.ts +5 -5
- package/src/ui/Chatify.tsx +9 -9
- package/src/ui/Conversation/Conversation.tsx +78 -76
- package/src/ui/Conversation/ConversationActions.tsx +5 -5
- package/src/ui/Conversation/ConversationBody.tsx +28 -28
- package/src/ui/Conversation/ConversationContext.ts +29 -27
- package/src/ui/Conversation/ConversationHeader.tsx +23 -23
- package/src/ui/Conversation/ConversationName.tsx +7 -7
- package/src/ui/Conversation/InputBox/InputBox.tsx +113 -40
- package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -0
- package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -0
- package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -9
- package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -17
- package/src/ui/Conversation/InputBox/InputTextBox.tsx +55 -53
- package/src/ui/Conversation/InputBox/index.ts +23 -16
- package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
- package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
- package/src/ui/Conversation/Message/MessageContent.tsx +15 -11
- package/src/ui/Conversation/Message/MessageFile.tsx +52 -0
- package/src/ui/Conversation/Message/MessageFileList.tsx +14 -0
- package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
- package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
- package/src/ui/Conversation/Message/MessageText.tsx +7 -7
- package/src/ui/Conversation/Message/index.ts +28 -22
- package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
- package/src/ui/Conversation/NextObserver/index.ts +1 -1
- package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
- package/src/ui/Conversation/ReadObserver/index.ts +1 -1
- package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
- package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
- package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
- package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
- package/src/ui/Conversation/SendingMessage/index.ts +16 -16
- package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
- package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
- package/src/ui/Conversation/SystemMessage/index.ts +10 -10
- package/src/ui/Conversation/index.ts +13 -13
- package/src/ui/Thread/ThreadActions.tsx +22 -22
- package/src/ui/Thread/ThreadContext.ts +13 -13
- package/src/ui/Thread/ThreadPanel.tsx +127 -127
- package/src/ui/Thread/index.tsx +3 -3
- package/src/ui/color.ts +20 -20
- package/src/ui/common/Avatar.tsx +20 -20
- package/src/ui/common/Icon.tsx +44 -40
- package/src/ui/common/MessageSkeleton.tsx +20 -20
- package/src/ui/common/index.ts +13 -13
- package/src/ui/customize.tsx +51 -53
- package/src/ui/index.ts +11 -11
- package/src/ui/localizer.tsx +96 -81
- package/src/ui/useFormatter.tsx +17 -0
- package/dist/esm/types/core/api/accountApi.d.ts +0 -5
- package/dist/esm/types/core/api/chatApi.d.ts +0 -16
- package/dist/esm/types/core/api/chatListApi.d.ts +0 -5
- package/dist/esm/types/core/api/chatMemberApi.d.ts +0 -6
- package/dist/esm/types/core/api/chatMessageApi.d.ts +0 -3
- package/dist/esm/types/core/api/threadApi.d.ts +0 -1
- package/dist/esm/types/core/api/threadMessageApi.d.ts +0 -6
- package/src/core/api/accountApi.ts +0 -11
- package/src/core/api/chatApi.ts +0 -87
- package/src/core/api/chatListApi.ts +0 -134
- package/src/core/api/chatMemberApi.ts +0 -20
- package/src/core/api/chatMessageApi.ts +0 -12
- package/src/core/api/threadApi.ts +0 -8
- package/src/core/api/threadMessageApi.ts +0 -20
- package/src/types/core/api/accountApi.d.ts +0 -5
- package/src/types/core/api/api.d.ts +0 -2380
- package/src/types/core/api/baseApi.d.ts +0 -15
- package/src/types/core/api/chatApi.d.ts +0 -16
- package/src/types/core/api/chatListApi.d.ts +0 -5
- package/src/types/core/api/chatMemberApi.d.ts +0 -6
- package/src/types/core/api/chatMessageApi.d.ts +0 -3
- package/src/types/core/api/index.d.ts +0 -1
- package/src/types/core/api/threadApi.d.ts +0 -1
- package/src/types/core/api/threadMessageApi.d.ts +0 -6
- package/src/types/core/client.d.ts +0 -83
- package/src/types/core/constants.d.ts +0 -1
- package/src/types/core/debounce.d.ts +0 -27
- package/src/types/core/index.d.ts +0 -4
- package/src/types/core/types.d.ts +0 -105
- package/src/types/index.d.ts +0 -2
- package/src/types/ui/Chat/ChatContext.d.ts +0 -10
- package/src/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
- package/src/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
- package/src/types/ui/Chat/ChatPanel.d.ts +0 -13
- package/src/types/ui/Chat/ChatView.d.ts +0 -17
- package/src/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
- package/src/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
- package/src/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
- package/src/types/ui/Chat/Members/index.d.ts +0 -11
- package/src/types/ui/Chat/index.d.ts +0 -6
- package/src/types/ui/ChatGroup/ChatGroupContext.d.ts +0 -12
- package/src/types/ui/ChatGroup/ChatGroupPanel.d.ts +0 -15
- package/src/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
- package/src/types/ui/ChatGroup/Create/CreateChatForm.d.ts +0 -11
- package/src/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
- package/src/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
- package/src/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
- package/src/types/ui/ChatGroup/Create/index.d.ts +0 -17
- package/src/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
- package/src/types/ui/ChatGroup/Layout/index.d.ts +0 -17
- package/src/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
- package/src/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
- package/src/types/ui/ChatGroup/List/index.d.ts +0 -29
- package/src/types/ui/ChatGroup/index.d.ts +0 -5
- package/src/types/ui/Chatify.d.ts +0 -8
- package/src/types/ui/Conversation/Conversation.d.ts +0 -21
- package/src/types/ui/Conversation/ConversationActions.d.ts +0 -2
- package/src/types/ui/Conversation/ConversationBody.d.ts +0 -2
- package/src/types/ui/Conversation/ConversationContext.d.ts +0 -20
- package/src/types/ui/Conversation/ConversationHeader.d.ts +0 -2
- package/src/types/ui/Conversation/ConversationName.d.ts +0 -2
- package/src/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
- package/src/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -2
- package/src/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -5
- package/src/types/ui/Conversation/InputBox/InputTextBox.d.ts +0 -8
- package/src/types/ui/Conversation/InputBox/index.d.ts +0 -14
- package/src/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
- package/src/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
- package/src/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
- package/src/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
- package/src/types/ui/Conversation/Message/MessageRow.d.ts +0 -6
- package/src/types/ui/Conversation/Message/MessageText.d.ts +0 -3
- package/src/types/ui/Conversation/Message/index.d.ts +0 -20
- package/src/types/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -5
- package/src/types/ui/Conversation/NextObserver/index.d.ts +0 -1
- package/src/types/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -6
- package/src/types/ui/Conversation/ReadObserver/index.d.ts +0 -1
- package/src/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
- package/src/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
- package/src/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
- package/src/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
- package/src/types/ui/Conversation/SendingMessage/index.d.ts +0 -14
- package/src/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
- package/src/types/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +0 -9
- package/src/types/ui/Conversation/SystemMessage/index.d.ts +0 -8
- package/src/types/ui/Conversation/index.d.ts +0 -12
- package/src/types/ui/Thread/ThreadActions.d.ts +0 -2
- package/src/types/ui/Thread/ThreadContext.d.ts +0 -8
- package/src/types/ui/Thread/ThreadPanel.d.ts +0 -14
- package/src/types/ui/Thread/index.d.ts +0 -3
- package/src/types/ui/color.d.ts +0 -6
- package/src/types/ui/common/Avatar.d.ts +0 -6
- package/src/types/ui/common/Icon.d.ts +0 -20
- package/src/types/ui/common/MessageSkeleton.d.ts +0 -5
- package/src/types/ui/common/index.d.ts +0 -11
- package/src/types/ui/customize.d.ts +0 -9
- package/src/types/ui/index.d.ts +0 -11
- package/src/types/ui/localizer.d.ts +0 -35
package/src/ui/common/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Avatar } from './Avatar';
|
|
2
|
-
import { Icon } from './Icon';
|
|
3
|
-
import { MessageSkeleton } from './MessageSkeleton';
|
|
4
|
-
|
|
5
|
-
export * from './Avatar';
|
|
6
|
-
export * from './Icon';
|
|
7
|
-
export * from './MessageSkeleton';
|
|
8
|
-
|
|
9
|
-
export interface CommonCustomizeValue {
|
|
10
|
-
Avatar?: typeof Avatar.Component | null;
|
|
11
|
-
Icon?: typeof Icon.Component | null;
|
|
12
|
-
MessageSkeleton?: typeof MessageSkeleton.Component | null;
|
|
13
|
-
}
|
|
1
|
+
import { Avatar } from './Avatar';
|
|
2
|
+
import { Icon } from './Icon';
|
|
3
|
+
import { MessageSkeleton } from './MessageSkeleton';
|
|
4
|
+
|
|
5
|
+
export * from './Avatar';
|
|
6
|
+
export * from './Icon';
|
|
7
|
+
export * from './MessageSkeleton';
|
|
8
|
+
|
|
9
|
+
export interface CommonCustomizeValue {
|
|
10
|
+
Avatar?: typeof Avatar.Component | null;
|
|
11
|
+
Icon?: typeof Icon.Component | null;
|
|
12
|
+
MessageSkeleton?: typeof MessageSkeleton.Component | null;
|
|
13
|
+
}
|
package/src/ui/customize.tsx
CHANGED
|
@@ -1,53 +1,51 @@
|
|
|
1
|
-
import React, { FC, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
export type Customizable<TComponent extends React.ComponentType<any>> = TComponent & {
|
|
4
|
-
Component: TComponent;
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const CustomizeContext = React.createContext<
|
|
9
|
-
|
|
10
|
-
>(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Result
|
|
51
|
-
|
|
52
|
-
return Object.assign(Result, { key, Component }) as any;
|
|
53
|
-
}
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export type Customizable<TComponent extends React.ComponentType<any>> = TComponent & {
|
|
4
|
+
Component: TComponent;
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const CustomizeContext = React.createContext<Record<string, any>>(null!);
|
|
9
|
+
|
|
10
|
+
export function useCustomizeContext<TValue>() {
|
|
11
|
+
return useContext(CustomizeContext) as TValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function useCustom<TComponent extends React.ComponentType>(key: string): TComponent | undefined | null {
|
|
15
|
+
const value = useContext(CustomizeContext);
|
|
16
|
+
return value ? (value[key] as TComponent | null | undefined) : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useCustomize<TCustom extends Customizable<React.ComponentType<any>>>(custom: TCustom) {
|
|
20
|
+
const Custom = useCustom<TCustom['Component']>(custom.key);
|
|
21
|
+
|
|
22
|
+
if (Custom == null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return Custom ?? custom.Component;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function customize<TComponent extends React.ComponentType<any>>(
|
|
30
|
+
key: string,
|
|
31
|
+
Component: TComponent,
|
|
32
|
+
): TComponent extends React.ComponentType<infer X> ? Customizable<React.ComponentType<X>> : never {
|
|
33
|
+
const Result: FC<any> = React.forwardRef<TComponent, any>((props: any, forwardRef) => {
|
|
34
|
+
const Custom = useCustom(key);
|
|
35
|
+
|
|
36
|
+
if (Custom === null) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (Custom) {
|
|
41
|
+
return <Custom {...props} ref={forwardRef} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return <Component {...props} ref={forwardRef} />;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
Component.displayName = Component.displayName || key;
|
|
48
|
+
Result.displayName = 'Customizable.' + Component.displayName;
|
|
49
|
+
|
|
50
|
+
return Object.assign(Result, { key, Component }) as any;
|
|
51
|
+
}
|
package/src/ui/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './color';
|
|
2
|
-
export * from './customize';
|
|
3
|
-
export * from './Chatify';
|
|
4
|
-
export * from './localizer';
|
|
5
|
-
export * from './Chat';
|
|
6
|
-
export * from './ChatGroup';
|
|
7
|
-
export * from './Conversation';
|
|
8
|
-
export * from './Thread';
|
|
9
|
-
export * from './common/Icon';
|
|
10
|
-
export * from './common/Avatar';
|
|
11
|
-
export * from './common/MessageSkeleton';
|
|
1
|
+
export * from './color';
|
|
2
|
+
export * from './customize';
|
|
3
|
+
export * from './Chatify';
|
|
4
|
+
export * from './localizer';
|
|
5
|
+
export * from './Chat';
|
|
6
|
+
export * from './ChatGroup';
|
|
7
|
+
export * from './Conversation';
|
|
8
|
+
export * from './Thread';
|
|
9
|
+
export * from './common/Icon';
|
|
10
|
+
export * from './common/Avatar';
|
|
11
|
+
export * from './common/MessageSkeleton';
|
package/src/ui/localizer.tsx
CHANGED
|
@@ -1,81 +1,96 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import React, { useContext } from 'react';
|
|
3
|
-
import { SystemMessageText } from '../core';
|
|
4
|
-
|
|
5
|
-
export interface Localizer {
|
|
6
|
-
isToday: (value: string) => boolean;
|
|
7
|
-
timestamp: (value: string) => string;
|
|
8
|
-
dateTime: (value: string) => string;
|
|
9
|
-
system: Record<SystemMessageText, (key: SystemMessageText, payload: any | null) => string>;
|
|
10
|
-
message: {
|
|
11
|
-
read: () => React.ReactNode;
|
|
12
|
-
reading: () => React.ReactNode;
|
|
13
|
-
sending: () => React.ReactNode;
|
|
14
|
-
};
|
|
15
|
-
addChat: {
|
|
16
|
-
title: () => React.ReactNode;
|
|
17
|
-
name: {
|
|
18
|
-
label: () => React.ReactNode;
|
|
19
|
-
required: () => string;
|
|
20
|
-
max250: () => string;
|
|
21
|
-
};
|
|
22
|
-
members: {
|
|
23
|
-
label: () => React.ReactNode;
|
|
24
|
-
required: () => string;
|
|
25
|
-
};
|
|
26
|
-
submitBtn: () => React.ReactNode;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
input: {
|
|
30
|
-
placeholder: () => string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
settings: {
|
|
34
|
-
members: () => string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { SystemMessageText } from '../core';
|
|
4
|
+
|
|
5
|
+
export interface Localizer {
|
|
6
|
+
isToday: (value: string) => boolean;
|
|
7
|
+
timestamp: (value: string) => string;
|
|
8
|
+
dateTime: (value: string) => string;
|
|
9
|
+
system: Record<SystemMessageText, (key: SystemMessageText, payload: any | null) => string>;
|
|
10
|
+
message: {
|
|
11
|
+
read: () => React.ReactNode;
|
|
12
|
+
reading: () => React.ReactNode;
|
|
13
|
+
sending: () => React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
addChat: {
|
|
16
|
+
title: () => React.ReactNode;
|
|
17
|
+
name: {
|
|
18
|
+
label: () => React.ReactNode;
|
|
19
|
+
required: () => string;
|
|
20
|
+
max250: () => string;
|
|
21
|
+
};
|
|
22
|
+
members: {
|
|
23
|
+
label: () => React.ReactNode;
|
|
24
|
+
required: () => string;
|
|
25
|
+
};
|
|
26
|
+
submitBtn: () => React.ReactNode;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
input: {
|
|
30
|
+
placeholder: () => string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
settings: {
|
|
34
|
+
members: () => string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
size: {
|
|
38
|
+
bytes: (value: number) => string;
|
|
39
|
+
kb: (value: number) => string;
|
|
40
|
+
mb: (value: number) => string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const LocalizerContext = React.createContext<Localizer>(null!);
|
|
45
|
+
|
|
46
|
+
export function useLocalizer() {
|
|
47
|
+
return useContext(LocalizerContext);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const defaultLocalizer: Localizer = {
|
|
51
|
+
isToday: (value: string) => dayjs(value).isSame(dayjs(), 'day'),
|
|
52
|
+
timestamp: (value: string) => dayjs(value).format('HH:mm'),
|
|
53
|
+
dateTime: (value: string) => dayjs(value).format('DD/MM/YYYY HH:mm'),
|
|
54
|
+
message: {
|
|
55
|
+
read: () => 'Read',
|
|
56
|
+
reading: () => 'Reading...',
|
|
57
|
+
sending: () => 'Sending...',
|
|
58
|
+
},
|
|
59
|
+
addChat: {
|
|
60
|
+
title: () => 'Add chat',
|
|
61
|
+
name: {
|
|
62
|
+
label: () => 'Name',
|
|
63
|
+
required: () => `Name is required`,
|
|
64
|
+
max250: () => 'Max 250 characters allowed',
|
|
65
|
+
},
|
|
66
|
+
members: {
|
|
67
|
+
label: () => 'Members',
|
|
68
|
+
required: () => 'Members is required',
|
|
69
|
+
},
|
|
70
|
+
submitBtn: () => 'Submit',
|
|
71
|
+
},
|
|
72
|
+
system: {
|
|
73
|
+
'chatify://chat-created': () => 'Chat created',
|
|
74
|
+
'chatify://member-added': () => 'New member added',
|
|
75
|
+
'chatify://member-removed': () => 'Member removed',
|
|
76
|
+
'chatify://chat-name-changed': (_, { newName }: { newName: string }) =>
|
|
77
|
+
`Chat name changed to '${newName}'`,
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
input: {
|
|
81
|
+
placeholder: () => 'Start typing (Ctrl/⌘Cmd + Enter to send) ...',
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
settings: {
|
|
85
|
+
members: () => 'Members',
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
size: {
|
|
89
|
+
bytes: (value: number) =>
|
|
90
|
+
`${value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} bytes`,
|
|
91
|
+
kb: (value: number) =>
|
|
92
|
+
`${value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} KB`,
|
|
93
|
+
mb: (value: number) =>
|
|
94
|
+
`${value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} MB`,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useLocalizer } from './localizer';
|
|
2
|
+
|
|
3
|
+
export function useFormatter() {
|
|
4
|
+
const localizer = useLocalizer();
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
size: (value: number) => {
|
|
8
|
+
if (value < 1024) {
|
|
9
|
+
return localizer.size.bytes(value);
|
|
10
|
+
} else if (value < 1024 * 1024) {
|
|
11
|
+
return localizer.size.kb(value / 1024);
|
|
12
|
+
} else {
|
|
13
|
+
return localizer.size.mb(value / 1024 / 1024);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder } from './baseApi';
|
|
2
|
-
import { Account } from '../types';
|
|
3
|
-
export declare function accountEndpoints(builder: BaseApiEndpointBuilder): {
|
|
4
|
-
getAccountList: import("@reduxjs/toolkit/query").QueryDefinition<void, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", Account[], "chatify">;
|
|
5
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder } from './baseApi';
|
|
2
|
-
import { Chat } from '../types';
|
|
3
|
-
export declare function chatEndpoints(builder: BaseApiEndpointBuilder): {};
|
|
4
|
-
export declare const __chatApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn, {
|
|
5
|
-
getChat: import("@reduxjs/toolkit/query").QueryDefinition<{
|
|
6
|
-
id: string;
|
|
7
|
-
}, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", Chat, "chatify">;
|
|
8
|
-
addChat: import("@reduxjs/toolkit/query").MutationDefinition<{
|
|
9
|
-
name: string;
|
|
10
|
-
members: string[];
|
|
11
|
-
}, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", string, "chatify">;
|
|
12
|
-
updateChatName: import("@reduxjs/toolkit/query").MutationDefinition<{
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", void, "chatify">;
|
|
16
|
-
}, "chatify", "chat" | "account" | "message" | "thread" | "thread-message", typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder } from './baseApi';
|
|
2
|
-
import { ChatListItem } from '../types';
|
|
3
|
-
export declare function chatListEndpoints(builder: BaseApiEndpointBuilder): {
|
|
4
|
-
getChatList: import("@reduxjs/toolkit/query").QueryDefinition<void, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", ChatListItem[], "chatify">;
|
|
5
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AddChatMemberRequest, RemoveChatMemberRequest } from '../types';
|
|
2
|
-
import { BaseApiEndpointBuilder } from './baseApi';
|
|
3
|
-
export declare function chatMemberEndpoints(builder: BaseApiEndpointBuilder): {
|
|
4
|
-
removeChatMember: import("@reduxjs/toolkit/query").MutationDefinition<RemoveChatMemberRequest, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", void, "chatify">;
|
|
5
|
-
addChatMember: import("@reduxjs/toolkit/query").MutationDefinition<AddChatMemberRequest, import("@reduxjs/toolkit/query").BaseQueryFn, "chat" | "account" | "message" | "thread" | "thread-message", void, "chatify">;
|
|
6
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder } from './baseApi';
|
|
2
|
-
export declare function chatMessageEndpoints(builder: BaseApiEndpointBuilder): {};
|
|
3
|
-
export declare const __chatMessageApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn, {}, "chatify", "chat" | "account" | "message" | "thread" | "thread-message", typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const __threadApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn, {}, "chatify", "chat" | "account" | "message" | "thread" | "thread-message", typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ThreadMessage } from '../types';
|
|
2
|
-
export interface ThreadMessageList {
|
|
3
|
-
messages: ThreadMessage[];
|
|
4
|
-
hasMore: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const __threadMessageApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn, {}, "chatify", "chat" | "account" | "message" | "thread" | "thread-message", typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder, __settings } from './baseApi';
|
|
2
|
-
import { Account } from '../types';
|
|
3
|
-
|
|
4
|
-
export function accountEndpoints(builder: BaseApiEndpointBuilder) {
|
|
5
|
-
return {
|
|
6
|
-
getAccountList: builder.query<Account[], void>({
|
|
7
|
-
queryFn: async () => ({ data: await __settings.client.accounts() }),
|
|
8
|
-
providesTags: ['account'],
|
|
9
|
-
}),
|
|
10
|
-
};
|
|
11
|
-
}
|
package/src/core/api/chatApi.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder, __baseApi, __settings } from './baseApi';
|
|
2
|
-
import { unsubscribe } from '../client';
|
|
3
|
-
import { Chat } from '../types';
|
|
4
|
-
|
|
5
|
-
export function chatEndpoints(builder: BaseApiEndpointBuilder) {
|
|
6
|
-
return {};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const chatApi = __baseApi.injectEndpoints({
|
|
10
|
-
endpoints: (builder) => ({
|
|
11
|
-
getChat: builder.query<Chat, { id: string }>({
|
|
12
|
-
queryFn: async ({ id }) => ({ data: await __settings.client.chat(id) }),
|
|
13
|
-
providesTags: ['chat', 'account'],
|
|
14
|
-
onCacheEntryAdded: async ({ id }, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
|
|
15
|
-
await cacheDataLoaded;
|
|
16
|
-
|
|
17
|
-
unsubscribe(
|
|
18
|
-
__settings.client.subscribe(
|
|
19
|
-
'chatify://chat-member-added',
|
|
20
|
-
([chatId, _, account, message, , read]) =>
|
|
21
|
-
chatId === id &&
|
|
22
|
-
updateCachedData((chat) => {
|
|
23
|
-
chat.members.push(account);
|
|
24
|
-
chat.lastReadMessageId = read ? message.id : chat.lastReadMessageId;
|
|
25
|
-
}),
|
|
26
|
-
),
|
|
27
|
-
__settings.client.subscribe(
|
|
28
|
-
'chatify://chat-member-removed',
|
|
29
|
-
([chatId, accountId, , message, read]) =>
|
|
30
|
-
id === chatId &&
|
|
31
|
-
updateCachedData((chat) => {
|
|
32
|
-
chat.members = chat.members.filter((x) => x.id !== accountId);
|
|
33
|
-
chat.lastReadMessageId = read ? message.id : chat.lastReadMessageId;
|
|
34
|
-
}),
|
|
35
|
-
),
|
|
36
|
-
__settings.client.subscribe(
|
|
37
|
-
'chatify://chat-name-changed',
|
|
38
|
-
([chatId, newName, message, read]) =>
|
|
39
|
-
id === chatId &&
|
|
40
|
-
updateCachedData((chat) => {
|
|
41
|
-
chat.name = newName;
|
|
42
|
-
chat.lastReadMessageId = read ? message.id : chat.lastReadMessageId;
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
__settings.client.subscribe(
|
|
46
|
-
'chatify://chat-new-message',
|
|
47
|
-
([message]) =>
|
|
48
|
-
id === message.chatId &&
|
|
49
|
-
updateCachedData((chat) => {
|
|
50
|
-
chat.lastReadMessageId =
|
|
51
|
-
message.sentBy.id === __settings.me() ? message.id : chat.lastReadMessageId;
|
|
52
|
-
}),
|
|
53
|
-
),
|
|
54
|
-
__settings.client.subscribe(
|
|
55
|
-
'chatify://chat-message-read',
|
|
56
|
-
([events]) =>
|
|
57
|
-
events.find((x) => x.chatId === id) &&
|
|
58
|
-
updateCachedData((chat) => {
|
|
59
|
-
const event = events.find((x) => x.chatId === id)!;
|
|
60
|
-
chat.lastReadMessageId = event.newLastReadMessageId;
|
|
61
|
-
}),
|
|
62
|
-
),
|
|
63
|
-
).when(cacheEntryRemoved);
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
|
|
67
|
-
addChat: builder.mutation<string, { name: string; members: string[] }>({
|
|
68
|
-
queryFn: async ({ name, members }) => {
|
|
69
|
-
const chatId = await __settings.client.addChat({
|
|
70
|
-
name,
|
|
71
|
-
members,
|
|
72
|
-
requestId: new Date().getTime().toString(),
|
|
73
|
-
});
|
|
74
|
-
return { data: chatId };
|
|
75
|
-
},
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
updateChatName: builder.mutation<void, { id: string; name: string }>({
|
|
79
|
-
queryFn: async ({ id, name }) => {
|
|
80
|
-
await __settings.client.updateChatName({ id, name });
|
|
81
|
-
return { data: null! };
|
|
82
|
-
},
|
|
83
|
-
}),
|
|
84
|
-
}),
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export const __chatApi = chatApi;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { BaseApiEndpointBuilder, __settings } from './baseApi';
|
|
2
|
-
import { unsubscribe } from '../client';
|
|
3
|
-
import { ChatListItem } from '../types';
|
|
4
|
-
|
|
5
|
-
export function chatListEndpoints(builder: BaseApiEndpointBuilder) {
|
|
6
|
-
return {
|
|
7
|
-
getChatList: builder.query<ChatListItem[], void>({
|
|
8
|
-
queryFn: async () => ({ data: await __settings.client.chats() }),
|
|
9
|
-
providesTags: ['chat', 'account'],
|
|
10
|
-
onCacheEntryAdded: async (_, { cacheEntryRemoved, cacheDataLoaded, updateCachedData }) => {
|
|
11
|
-
await cacheDataLoaded;
|
|
12
|
-
|
|
13
|
-
unsubscribe(
|
|
14
|
-
__settings.client.subscribe('chatify://chat-created', ([chat]) =>
|
|
15
|
-
updateCachedData((chatList) => {
|
|
16
|
-
chatList.push(chat);
|
|
17
|
-
}),
|
|
18
|
-
),
|
|
19
|
-
|
|
20
|
-
__settings.client.subscribe('chatify://chat-new-message', ([message]) =>
|
|
21
|
-
updateCachedData((chatList) => {
|
|
22
|
-
const chat = chatList.find((x) => x.id === message.chatId);
|
|
23
|
-
|
|
24
|
-
if (!chat) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
chat.message = message;
|
|
29
|
-
|
|
30
|
-
if (message.sentBy.id === __settings.me()) {
|
|
31
|
-
chat.lastReadMessageId = message.id;
|
|
32
|
-
chat.totalUnreadCount = 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (message.sentBy.id !== __settings.me()) {
|
|
36
|
-
chat.totalUnreadCount++;
|
|
37
|
-
}
|
|
38
|
-
}),
|
|
39
|
-
),
|
|
40
|
-
__settings.client.subscribe('chatify://chat-message-read', ([events]) =>
|
|
41
|
-
updateCachedData((chatList) => {
|
|
42
|
-
for (const event of events) {
|
|
43
|
-
const chat = chatList.find((x) => x.id === event.chatId);
|
|
44
|
-
|
|
45
|
-
if (!chat) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
chat.lastReadMessageId = event.newLastReadMessageId;
|
|
50
|
-
chat.totalUnreadCount = chat.totalUnreadCount - event.readCount;
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
),
|
|
54
|
-
__settings.client.subscribe(
|
|
55
|
-
'chatify://chat-member-added',
|
|
56
|
-
([chatId, chatName, account, message, , read]) =>
|
|
57
|
-
updateCachedData((chatList) => {
|
|
58
|
-
const chat = chatList.find((x) => x.id === chatId);
|
|
59
|
-
|
|
60
|
-
if (account.id === __settings.me() && !chat) {
|
|
61
|
-
chatList.push({
|
|
62
|
-
id: chatId,
|
|
63
|
-
name: chatName,
|
|
64
|
-
message,
|
|
65
|
-
totalUnreadCount: read ? 0 : 1,
|
|
66
|
-
active: true,
|
|
67
|
-
lastReadMessageId: read ? message.id : null,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!chat) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
chat.message = message;
|
|
76
|
-
chat.active = true;
|
|
77
|
-
|
|
78
|
-
if (read) {
|
|
79
|
-
chat.totalUnreadCount = 0;
|
|
80
|
-
chat.lastReadMessageId = message.id;
|
|
81
|
-
} else {
|
|
82
|
-
chat.totalUnreadCount++;
|
|
83
|
-
}
|
|
84
|
-
}),
|
|
85
|
-
),
|
|
86
|
-
__settings.client.subscribe(
|
|
87
|
-
'chatify://chat-member-removed',
|
|
88
|
-
([chatId, accountId, deleteHistory, message, read]) =>
|
|
89
|
-
updateCachedData((chatList) => {
|
|
90
|
-
if (accountId === __settings.me() && deleteHistory) {
|
|
91
|
-
return chatList.filter((x) => x.id !== chatId);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const chat = chatList.find((x) => x.id === chatId);
|
|
95
|
-
|
|
96
|
-
if (!chat) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
chat.message = message;
|
|
101
|
-
|
|
102
|
-
if (accountId === __settings.me()) {
|
|
103
|
-
chat.active = false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (!read) {
|
|
107
|
-
chat.totalUnreadCount++;
|
|
108
|
-
} else {
|
|
109
|
-
chat.totalUnreadCount = 0;
|
|
110
|
-
chat.lastReadMessageId = message.id;
|
|
111
|
-
}
|
|
112
|
-
}),
|
|
113
|
-
),
|
|
114
|
-
__settings.client.subscribe('chatify://chat-name-changed', ([chatId, newName, message, read]) =>
|
|
115
|
-
updateCachedData((chatList) => {
|
|
116
|
-
const chat = chatList.find((x) => x.id === chatId);
|
|
117
|
-
if (!chat) return;
|
|
118
|
-
|
|
119
|
-
chat.name = newName;
|
|
120
|
-
chat.message = message;
|
|
121
|
-
|
|
122
|
-
if (!read) {
|
|
123
|
-
chat.totalUnreadCount++;
|
|
124
|
-
} else {
|
|
125
|
-
chat.totalUnreadCount = 0;
|
|
126
|
-
chat.lastReadMessageId = message.id;
|
|
127
|
-
}
|
|
128
|
-
}),
|
|
129
|
-
),
|
|
130
|
-
).when(cacheEntryRemoved);
|
|
131
|
-
},
|
|
132
|
-
}),
|
|
133
|
-
};
|
|
134
|
-
}
|