@webinex/chatify 2.0.0-alpha13 → 2.0.0-alpha14
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/{Chatify-CwAfN1wu.js → Chatify-CP2jgo8d.js} +191 -118
- package/dist/Chatify-CP2jgo8d.js.map +1 -0
- package/dist/Chatify.css +28 -0
- package/dist/audit.js +3 -2
- package/dist/audit.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/audit/index.d.ts +17 -15
- package/dist/types/ui/Chat/ChatContext.d.ts +2 -0
- package/dist/types/ui/Chat/ChatPanel.d.ts +7 -0
- package/dist/types/ui/Chat/ChatView.d.ts +4 -2
- package/dist/types/ui/ChatGroup/ChatGroupContext.d.ts +4 -1
- package/dist/types/ui/ChatGroup/ChatGroupPanel.d.ts +21 -2
- package/dist/types/ui/Conversation/Conversation.d.ts +1 -0
- package/dist/types/ui/Conversation/ConversationContext.d.ts +1 -0
- package/dist/types/ui/Conversation/ConversationHeader.d.ts +4 -1
- package/dist/types/ui/localizer.d.ts +4 -1
- package/dist/types/ui/useCompact.d.ts +4 -0
- package/package.json +81 -81
- package/src/audit/AuditChatList.tsx +25 -25
- package/src/audit/AuditConversationPanel.tsx +49 -48
- package/src/audit/AuditPanel.tsx +76 -76
- package/src/audit/AuditPanelCustomizeValue.ts +11 -11
- package/src/audit/AuditSearch.tsx +89 -89
- package/src/audit/AuditSearchValue.tsx +42 -42
- package/src/audit/auditApi.tsx +113 -113
- package/src/audit/index.d.ts +18 -18
- package/src/audit/index.tsx +28 -28
- package/src/audit/styles.scss +72 -72
- package/src/core/api/api.ts +675 -675
- package/src/core/api/baseApi.ts +38 -38
- package/src/core/api/index.ts +1 -1
- package/src/core/client.ts +298 -298
- 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 +182 -182
- package/src/index.ts +2 -2
- package/src/styles/aside.scss +34 -26
- package/src/styles/chat-list.scss +138 -138
- package/src/styles/chat.scss +11 -11
- package/src/styles/conversation.scss +199 -200
- package/src/styles/index.scss +227 -220
- package/src/styles/input.scss +148 -148
- package/src/styles/keyframes.scss +14 -14
- package/src/styles/members.scss +30 -13
- package/src/styles/mixins.scss +38 -25
- package/src/styles/variables.scss +13 -13
- package/src/ui/Chat/ChatContext.tsx +32 -30
- package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
- package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
- package/src/ui/Chat/ChatPanel.tsx +46 -30
- package/src/ui/Chat/ChatView.tsx +122 -115
- package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
- package/src/ui/Chat/Members/ChatMembersPanel.tsx +128 -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/AutoReply/AutoReplyButton.tsx +21 -21
- package/src/ui/ChatGroup/AutoReply/AutoReplyForm.tsx +50 -50
- package/src/ui/ChatGroup/AutoReply/AutoReplyPanel.tsx +94 -94
- package/src/ui/ChatGroup/AutoReply/AutoReplyPeriodInput.tsx +22 -22
- package/src/ui/ChatGroup/AutoReply/AutoReplyTextInput.tsx +22 -22
- package/src/ui/ChatGroup/AutoReply/index.ts +19 -19
- package/src/ui/ChatGroup/ChatGroupContext.tsx +63 -61
- package/src/ui/ChatGroup/ChatGroupPanel.tsx +110 -75
- 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/ChatGroupActions.tsx +15 -15
- package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
- package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +17 -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 +21 -19
- package/src/ui/ChatGroup/Layout/index.ts +22 -22
- package/src/ui/ChatGroup/List/ChatListPanel.tsx +28 -28
- package/src/ui/ChatGroup/List/index.ts +8 -8
- package/src/ui/ChatGroup/index.ts +6 -6
- package/src/ui/Chatify.tsx +15 -15
- package/src/ui/Conversation/Conversation.tsx +96 -92
- package/src/ui/Conversation/ConversationActions.tsx +12 -12
- package/src/ui/Conversation/ConversationBody.tsx +28 -28
- package/src/ui/Conversation/ConversationContext.ts +31 -30
- package/src/ui/Conversation/ConversationHeader.tsx +35 -19
- package/src/ui/Conversation/ConversationName.tsx +7 -7
- package/src/ui/Conversation/InputBox/InputBox.tsx +126 -126
- package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -38
- package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -21
- package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -78
- package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -26
- package/src/ui/Conversation/InputBox/InputTextBox.tsx +63 -61
- package/src/ui/Conversation/InputBox/index.ts +23 -23
- 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 -15
- package/src/ui/Conversation/Message/MessageFile.tsx +54 -54
- package/src/ui/Conversation/Message/MessageFileList.tsx +14 -14
- 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 -28
- 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 +128 -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/ChatList/ChatList.tsx +83 -84
- package/src/ui/common/ChatList/ChatListItemAvatar.tsx +22 -22
- package/src/ui/common/ChatList/ChatListItemBox.tsx +32 -32
- package/src/ui/common/ChatList/ChatListItemLastMessage.tsx +15 -15
- package/src/ui/common/ChatList/ChatListItemLastMessageAuthor.tsx +15 -15
- package/src/ui/common/ChatList/ChatListItemLastMessageContent.tsx +21 -21
- package/src/ui/common/ChatList/ChatListItemLastMessageSentAt.tsx +22 -22
- package/src/ui/common/ChatList/ChatListItemName.tsx +8 -8
- package/src/ui/common/ChatList/ChatListItemUnreadCount.tsx +12 -12
- package/src/ui/common/ChatList/ChatListValue.ts +9 -9
- package/src/ui/common/ChatList/index.ts +32 -32
- package/src/ui/common/Icon.tsx +48 -48
- package/src/ui/common/MessageSkeleton.tsx +20 -20
- package/src/ui/common/index.ts +14 -14
- package/src/ui/customize.tsx +51 -51
- package/src/ui/index.ts +11 -11
- package/src/ui/localizer.tsx +148 -137
- package/src/ui/useCompact.tsx +32 -0
- package/src/ui/useFormatter.tsx +17 -17
- package/dist/Chatify-CwAfN1wu.js.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { ChatMembersPreview } from './Members';
|
|
2
|
-
import { ChatMembersButton } from './Members';
|
|
3
|
-
import { customize } from '../customize';
|
|
4
|
-
import { useConversation } from '../Conversation';
|
|
5
|
-
|
|
6
|
-
export const ChatHeaderActions = customize('ChatHeaderActions', () => {
|
|
7
|
-
const { active } = useConversation();
|
|
8
|
-
|
|
9
|
-
if (!active) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div className="wxchtf-chat-members">
|
|
15
|
-
<ChatMembersPreview />
|
|
16
|
-
<ChatMembersButton />
|
|
17
|
-
</div>
|
|
18
|
-
);
|
|
19
|
-
});
|
|
1
|
+
import { ChatMembersPreview } from './Members';
|
|
2
|
+
import { ChatMembersButton } from './Members';
|
|
3
|
+
import { customize } from '../customize';
|
|
4
|
+
import { useConversation } from '../Conversation';
|
|
5
|
+
|
|
6
|
+
export const ChatHeaderActions = customize('ChatHeaderActions', () => {
|
|
7
|
+
const { active, compact } = useConversation();
|
|
8
|
+
|
|
9
|
+
if (!active) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="wxchtf-chat-members">
|
|
15
|
+
{!compact && <ChatMembersPreview />}
|
|
16
|
+
<ChatMembersButton />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
|
-
import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
|
|
3
|
-
import { CustomizeContext } from '../customize';
|
|
4
|
-
import { ChatView, ChatViewCustomizeValue } from './ChatView';
|
|
5
|
-
import { chatifyApi } from '../../core';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
|
|
3
|
+
import { CustomizeContext } from '../customize';
|
|
4
|
+
import { ChatView, ChatViewCustomizeValue } from './ChatView';
|
|
5
|
+
import { chatifyApi } from '../../core';
|
|
6
|
+
import { useCompact } from '../useCompact';
|
|
7
|
+
|
|
8
|
+
export interface ChatPanelCustomizeValue extends ChatViewCustomizeValue {}
|
|
9
|
+
|
|
10
|
+
export interface ChatPanelProps {
|
|
11
|
+
id: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
localizer?: Localizer;
|
|
15
|
+
customize?: ChatPanelCustomizeValue;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* If true, the chat panel will be displayed in compact mode.
|
|
19
|
+
* If a number is provided, the chat panel will be displayed in compact mode if its width is less than the provided number of pixels.
|
|
20
|
+
*
|
|
21
|
+
* @default 768
|
|
22
|
+
*/
|
|
23
|
+
compact?: boolean | number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ChatPanel(props: ChatPanelProps) {
|
|
27
|
+
const { id, className = '', customize, localizer = defaultLocalizer, style, compact: compactProp } = props;
|
|
28
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
29
|
+
const [ref, compact] = useCompact(compactProp);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
className={['wxchtf-chatify', 'wxchtf-chat-panel', compact && '--compact', className]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.join(' ')}
|
|
36
|
+
style={style}
|
|
37
|
+
ref={ref}
|
|
38
|
+
>
|
|
39
|
+
<LocalizerContext.Provider value={localizer}>
|
|
40
|
+
<CustomizeContext.Provider value={customize as any}>
|
|
41
|
+
{chat && <ChatView value={chat} key={id} compact={compact} />}
|
|
42
|
+
</CustomizeContext.Provider>
|
|
43
|
+
</LocalizerContext.Provider>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
package/src/ui/Chat/ChatView.tsx
CHANGED
|
@@ -1,115 +1,122 @@
|
|
|
1
|
-
import { CustomizeContext, customize, useCustomizeContext } from '../customize';
|
|
2
|
-
import { MessageBody, chatId, chatifyApi } from '../../core';
|
|
3
|
-
import {
|
|
4
|
-
Conversation,
|
|
5
|
-
ConversationCustomizeValue,
|
|
6
|
-
ConversationProps,
|
|
7
|
-
ConversationValue,
|
|
8
|
-
} from '../Conversation';
|
|
9
|
-
import { useCallback, useMemo } from 'react';
|
|
10
|
-
import { ChatEditableHeaderName } from './ChatEditableHeaderName';
|
|
11
|
-
import { ChatHeaderActions } from './ChatHeaderActions';
|
|
12
|
-
import { ChatMembersCustomizeValue, ChatMembersPanel } from './Members';
|
|
13
|
-
import { ChatContext, useChatContext } from './ChatContext';
|
|
14
|
-
|
|
15
|
-
export interface
|
|
16
|
-
value: ChatValue;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export interface
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const [
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const [
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
import { CustomizeContext, customize, useCustomizeContext } from '../customize';
|
|
2
|
+
import { MessageBody, chatId, chatifyApi } from '../../core';
|
|
3
|
+
import {
|
|
4
|
+
Conversation,
|
|
5
|
+
ConversationCustomizeValue,
|
|
6
|
+
ConversationProps,
|
|
7
|
+
ConversationValue,
|
|
8
|
+
} from '../Conversation';
|
|
9
|
+
import { useCallback, useMemo } from 'react';
|
|
10
|
+
import { ChatEditableHeaderName } from './ChatEditableHeaderName';
|
|
11
|
+
import { ChatHeaderActions } from './ChatHeaderActions';
|
|
12
|
+
import { ChatMembersCustomizeValue, ChatMembersPanel } from './Members';
|
|
13
|
+
import { ChatContext, useChatContext } from './ChatContext';
|
|
14
|
+
|
|
15
|
+
export interface ChatViewProps {
|
|
16
|
+
value: ChatValue;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
onBackClick?: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ChatValue extends ConversationValue {}
|
|
22
|
+
|
|
23
|
+
export interface ChatViewCustomizeValue extends ConversationCustomizeValue, ChatMembersCustomizeValue {
|
|
24
|
+
ChatEditableHeaderName?: typeof ChatEditableHeaderName.Component | null;
|
|
25
|
+
ChatHeaderActions?: typeof ChatHeaderActions.Component | null;
|
|
26
|
+
ChatView?: typeof ChatView.Component | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE: ConversationCustomizeValue = {
|
|
30
|
+
ConversationName: () => <ChatEditableHeaderName />,
|
|
31
|
+
ConversationActions: () => <ChatHeaderActions />,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function useConversation(props: Pick<ChatViewProps, 'value' | 'onBackClick'>) {
|
|
35
|
+
const { value: chat, onBackClick } = props;
|
|
36
|
+
const { compact } = useChatContext();
|
|
37
|
+
const { id, name, active, lastReadMessageId } = chat;
|
|
38
|
+
|
|
39
|
+
const { data: messageList } = chatifyApi.useGetChatMessageListQuery({ chatId: id });
|
|
40
|
+
const { messages, hasMore } = messageList ?? {};
|
|
41
|
+
|
|
42
|
+
const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextChatMessageListMutation();
|
|
43
|
+
const onNext = useCallback(() => fetchNext({ chatId: id }), [fetchNext, id]);
|
|
44
|
+
|
|
45
|
+
const [read] = chatifyApi.useReadChatMessageMutation();
|
|
46
|
+
const onRead = useCallback((id: string) => read({ id }), [read]);
|
|
47
|
+
|
|
48
|
+
const [send] = chatifyApi.useSendChatMessageMutation();
|
|
49
|
+
const onSend = useCallback((message: MessageBody) => send({ ...message, chatId: id }).unwrap(), [id, send]);
|
|
50
|
+
|
|
51
|
+
const { data: readQueue } = chatifyApi.useGetChatMessageReadQueueQuery();
|
|
52
|
+
|
|
53
|
+
const conversation = useMemo(() => {
|
|
54
|
+
if (!id) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const result: ConversationProps = {
|
|
59
|
+
value: { id: id!, name: name!, active: active!, lastReadMessageId: lastReadMessageId! },
|
|
60
|
+
messages,
|
|
61
|
+
hasMore,
|
|
62
|
+
onNext,
|
|
63
|
+
nextLoading: isFetchNextLoading,
|
|
64
|
+
onRead,
|
|
65
|
+
onSend,
|
|
66
|
+
isReading: (id: string) => readQueue!.some((x) => chatId(x.value) === chatId(id) && id <= x.value),
|
|
67
|
+
compact: compact ?? false,
|
|
68
|
+
onBackClick,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
}, [
|
|
73
|
+
onNext,
|
|
74
|
+
onRead,
|
|
75
|
+
onSend,
|
|
76
|
+
isFetchNextLoading,
|
|
77
|
+
id,
|
|
78
|
+
name,
|
|
79
|
+
active,
|
|
80
|
+
messages,
|
|
81
|
+
hasMore,
|
|
82
|
+
lastReadMessageId,
|
|
83
|
+
readQueue,
|
|
84
|
+
compact,
|
|
85
|
+
onBackClick,
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
return conversation;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function Content(props: Pick<ChatViewProps, 'value' | 'onBackClick'>) {
|
|
92
|
+
const conversation = useConversation(props);
|
|
93
|
+
const { compact, showMembers } = useChatContext();
|
|
94
|
+
|
|
95
|
+
if (!conversation) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div className="wxchtf-chat">
|
|
101
|
+
{(!compact || !showMembers) && <Conversation {...conversation} />}
|
|
102
|
+
{showMembers && <ChatMembersPanel />}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const ChatView = customize('ChatView', (props: ChatViewProps) => {
|
|
108
|
+
const { value, compact, onBackClick } = props;
|
|
109
|
+
const customized = useCustomizeContext();
|
|
110
|
+
const customize: ChatViewCustomizeValue = useMemo(
|
|
111
|
+
() => ({ ...(customized ?? {}), ...DEFAULT_CHAT_VIEW_CUSTOMIZE_VALUE }),
|
|
112
|
+
[customized],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<CustomizeContext.Provider value={customize}>
|
|
117
|
+
<ChatContext id={value.id} compact={compact ?? false}>
|
|
118
|
+
<Content value={value} onBackClick={onBackClick} />
|
|
119
|
+
</ChatContext>
|
|
120
|
+
</CustomizeContext.Provider>
|
|
121
|
+
);
|
|
122
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Button } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { Icon } from '../../common/Icon';
|
|
4
|
-
import { useChatContext } from '../ChatContext';
|
|
5
|
-
|
|
6
|
-
export const ChatMembersButton = customize('ChatMembersButton', () => {
|
|
7
|
-
const { showMembers, onShowMembers } = useChatContext();
|
|
8
|
-
return <Button onClick={() => onShowMembers(!showMembers)} type="link" icon={<Icon type="members" />} />;
|
|
9
|
-
});
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { Icon } from '../../common/Icon';
|
|
4
|
+
import { useChatContext } from '../ChatContext';
|
|
5
|
+
|
|
6
|
+
export const ChatMembersButton = customize('ChatMembersButton', () => {
|
|
7
|
+
const { showMembers, onShowMembers } = useChatContext();
|
|
8
|
+
return <Button onClick={() => onShowMembers(!showMembers)} type="link" icon={<Icon type="members" />} />;
|
|
9
|
+
});
|
|
@@ -1,112 +1,128 @@
|
|
|
1
|
-
import { Button, List, Space, Tooltip } from 'antd';
|
|
2
|
-
import { chatifyApi } from '../../../core';
|
|
3
|
-
import { customize } from '../../customize';
|
|
4
|
-
import { useCallback, useMemo } from 'react';
|
|
5
|
-
import { Icon } from '../../common/Icon';
|
|
6
|
-
import { Avatar } from '../../common/Avatar';
|
|
7
|
-
import { useChatContext } from '../ChatContext';
|
|
8
|
-
|
|
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
|
-
const {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const [
|
|
41
|
-
const [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import { Button, Col, List, Row, Space, Tooltip } from 'antd';
|
|
2
|
+
import { chatifyApi } from '../../../core';
|
|
3
|
+
import { customize } from '../../customize';
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
|
+
import { Icon } from '../../common/Icon';
|
|
6
|
+
import { Avatar } from '../../common/Avatar';
|
|
7
|
+
import { useChatContext } from '../ChatContext';
|
|
8
|
+
import { LeftOutlined } from '@ant-design/icons';
|
|
9
|
+
import { useLocalizer } from '@/ui/localizer';
|
|
10
|
+
|
|
11
|
+
interface ChatMemberListItemProps {
|
|
12
|
+
id: string;
|
|
13
|
+
chatId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function useAdd(chatId: string, accountId: string, withHistory: boolean) {
|
|
17
|
+
const [add, state] = chatifyApi.useAddChatMemberMutation();
|
|
18
|
+
const onAdd = useCallback(
|
|
19
|
+
() => add({ chatId, accountId, withHistory }),
|
|
20
|
+
[add, chatId, accountId, withHistory],
|
|
21
|
+
);
|
|
22
|
+
return [onAdd, state] as const;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function useRemove(chatId: string, accountId: string, deleteHistory: boolean) {
|
|
26
|
+
const [remove, state] = chatifyApi.useRemoveChatMemberMutation();
|
|
27
|
+
const onRemove = useCallback(
|
|
28
|
+
() => remove({ chatId, accountId, deleteHistory }),
|
|
29
|
+
[remove, chatId, accountId, deleteHistory],
|
|
30
|
+
);
|
|
31
|
+
return [onRemove, state] as const;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const ChatMemberListItem = customize('ChatMemberListItem', (props: ChatMemberListItemProps) => {
|
|
35
|
+
const { chatId } = props;
|
|
36
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id: chatId });
|
|
37
|
+
const { data: accounts } = chatifyApi.useGetAccountListQuery({});
|
|
38
|
+
const account = accounts!.find((x) => x.id === props.id)!;
|
|
39
|
+
const isMember = chat!.members.some((x) => x.id === account.id);
|
|
40
|
+
const [onAddWithoutHistory] = useAdd(chatId, account.id, false);
|
|
41
|
+
const [onAddWithHistory] = useAdd(chatId, account.id, true);
|
|
42
|
+
const [onRemoveKeepHistory] = useRemove(chatId, account.id, false);
|
|
43
|
+
const [onRemoveDeleteHistory] = useRemove(chatId, account.id, true);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<List.Item
|
|
47
|
+
className="wxchtf-chat-members-list-item"
|
|
48
|
+
actions={
|
|
49
|
+
isMember
|
|
50
|
+
? [
|
|
51
|
+
<Tooltip key="remove" title="Remove (keep history)">
|
|
52
|
+
<Button onClick={onRemoveKeepHistory} type="link" icon={<Icon type="remove-member" />} />
|
|
53
|
+
</Tooltip>,
|
|
54
|
+
<Tooltip key="remove_delete_history" title="Remove (delete history)">
|
|
55
|
+
<Button
|
|
56
|
+
onClick={onRemoveDeleteHistory}
|
|
57
|
+
type="link"
|
|
58
|
+
icon={<Icon type="remove-member-delete-history" />}
|
|
59
|
+
/>
|
|
60
|
+
</Tooltip>,
|
|
61
|
+
]
|
|
62
|
+
: [
|
|
63
|
+
<Tooltip key="add_no_history" title="Add (no history)">
|
|
64
|
+
<Button onClick={onAddWithoutHistory} type="link" icon={<Icon type="add-member" />} />
|
|
65
|
+
</Tooltip>,
|
|
66
|
+
<Tooltip key="add" title="Add (share history)">
|
|
67
|
+
<Button
|
|
68
|
+
onClick={onAddWithHistory}
|
|
69
|
+
type="link"
|
|
70
|
+
icon={<Icon type="add-member-with-history" />}
|
|
71
|
+
/>
|
|
72
|
+
</Tooltip>,
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
>
|
|
76
|
+
<Space>
|
|
77
|
+
<Avatar account={account} />
|
|
78
|
+
<span>{account.name}</span>
|
|
79
|
+
</Space>
|
|
80
|
+
</List.Item>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export const ChatMembersPanel = customize('ChatMembersPanel', () => {
|
|
85
|
+
const { id, compact, onShowMembers } = useChatContext();
|
|
86
|
+
const localizer = useLocalizer();
|
|
87
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
88
|
+
const { data: accounts } = chatifyApi.useGetAccountListQuery({});
|
|
89
|
+
|
|
90
|
+
const ordered = useMemo(
|
|
91
|
+
() =>
|
|
92
|
+
accounts
|
|
93
|
+
?.slice()
|
|
94
|
+
.sort(
|
|
95
|
+
(a, b) =>
|
|
96
|
+
(chat?.members.some((m) => m.id === a.id) ? -100 : 0) -
|
|
97
|
+
(chat?.members.some((m) => m.id === b.id) ? -100 : 0) +
|
|
98
|
+
a.name.localeCompare(b.name),
|
|
99
|
+
),
|
|
100
|
+
[accounts, chat],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
if (!chat?.members || !accounts) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div className="wxchtf-chat-members-panel">
|
|
109
|
+
{compact && (
|
|
110
|
+
<div className="wxchtf-chat-members-panel-header">
|
|
111
|
+
<Row wrap={false} align="middle" gutter={10}>
|
|
112
|
+
<Col flex="none">
|
|
113
|
+
<Button type="text" icon={<LeftOutlined />} onClick={() => onShowMembers(false)} />
|
|
114
|
+
</Col>
|
|
115
|
+
<Col>
|
|
116
|
+
<span className="wxchtf-chat-members-panel-title">{localizer.members.title(chat.name)}</span>
|
|
117
|
+
</Col>
|
|
118
|
+
</Row>
|
|
119
|
+
</div>
|
|
120
|
+
)}
|
|
121
|
+
<List
|
|
122
|
+
className="wxchtf-chat-members-list"
|
|
123
|
+
dataSource={ordered}
|
|
124
|
+
renderItem={(item) => <ChatMemberListItem id={item.id} chatId={id} />}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
});
|