@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
package/src/core/constants.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SYSTEM_ID = 'chatify::system';
|
|
1
|
+
export const SYSTEM_ID = 'chatify::system';
|
package/src/core/debounce.ts
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
interface DebounceInternalValue<T> {
|
|
2
|
-
value: T;
|
|
3
|
-
enqueueTime: number;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface DebounceValue<T> extends DebounceInternalValue<T> {
|
|
7
|
-
state: 'enqueued' | 'processing';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface DebounceConfig<T> {
|
|
11
|
-
timeout: number;
|
|
12
|
-
callback: (value: T) => Promise<any>;
|
|
13
|
-
groupBy: (value: T) => string;
|
|
14
|
-
compare: (a: T, b: T) => number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Debounce<T> {
|
|
18
|
-
private _enqueued: DebounceInternalValue<T>[] = [];
|
|
19
|
-
private _processing: DebounceInternalValue<T>[] = [];
|
|
20
|
-
private _timeoutByGroup: Record<string, number> = {};
|
|
21
|
-
private _subscribers: ((value: Debounce<T>) => any)[] = [];
|
|
22
|
-
|
|
23
|
-
constructor(public config: DebounceConfig<T>) {}
|
|
24
|
-
|
|
25
|
-
public get units(): DebounceValue<T>[] {
|
|
26
|
-
return [
|
|
27
|
-
...this._enqueued.map((x) => ({ ...x, state: 'enqueued' as const })),
|
|
28
|
-
...this._processing.map((x) => ({ ...x, state: 'processing' as const })),
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public subscribe = (callback: (value: Debounce<T>) => any) => {
|
|
33
|
-
this._subscribers.push(callback);
|
|
34
|
-
return () => {
|
|
35
|
-
this._subscribers = this._subscribers.filter((x) => x !== callback);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
public notify = () => {
|
|
40
|
-
this._subscribers.forEach((subscriber) => subscriber(this));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
public push(value: T) {
|
|
44
|
-
const group = this.config.groupBy(value);
|
|
45
|
-
const unit = this._enqueued.find((unit) => this.config.groupBy(unit.value) === group);
|
|
46
|
-
|
|
47
|
-
if (!unit) {
|
|
48
|
-
this._enqueued.push({ value, enqueueTime: Date.now() });
|
|
49
|
-
} else if (this.config.compare(unit.value, value) >= 0) {
|
|
50
|
-
unit.value = value;
|
|
51
|
-
unit.enqueueTime = Date.now();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this._process(group);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private _process(group: string) {
|
|
58
|
-
if (!this._enqueued.some((unit) => this.config.groupBy(unit.value) === group)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let timeout = this._timeoutByGroup[group];
|
|
63
|
-
timeout && clearTimeout(timeout);
|
|
64
|
-
|
|
65
|
-
if (this._processing.some((unit) => this.config.groupBy(unit.value) === group)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
timeout = setTimeout(() => {
|
|
70
|
-
const processing = this._enqueued.find((unit) => this.config.groupBy(unit.value) === group)!;
|
|
71
|
-
this._processing.push(processing);
|
|
72
|
-
this._enqueued.splice(this._enqueued.indexOf(processing), 1);
|
|
73
|
-
this.notify();
|
|
74
|
-
|
|
75
|
-
this.config
|
|
76
|
-
.callback(processing.value)
|
|
77
|
-
.then(() => {
|
|
78
|
-
this._processing.splice(this._processing.indexOf(processing), 1);
|
|
79
|
-
this.notify();
|
|
80
|
-
this._process(group);
|
|
81
|
-
})
|
|
82
|
-
.catch(() => {
|
|
83
|
-
this._processing.splice(this._processing.indexOf(processing), 1);
|
|
84
|
-
this.push(processing.value);
|
|
85
|
-
});
|
|
86
|
-
}, this.config.timeout);
|
|
87
|
-
|
|
88
|
-
this._timeoutByGroup[group] = timeout;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
interface DebounceInternalValue<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
enqueueTime: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface DebounceValue<T> extends DebounceInternalValue<T> {
|
|
7
|
+
state: 'enqueued' | 'processing';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DebounceConfig<T> {
|
|
11
|
+
timeout: number;
|
|
12
|
+
callback: (value: T) => Promise<any>;
|
|
13
|
+
groupBy: (value: T) => string;
|
|
14
|
+
compare: (a: T, b: T) => number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class Debounce<T> {
|
|
18
|
+
private _enqueued: DebounceInternalValue<T>[] = [];
|
|
19
|
+
private _processing: DebounceInternalValue<T>[] = [];
|
|
20
|
+
private _timeoutByGroup: Record<string, number> = {};
|
|
21
|
+
private _subscribers: ((value: Debounce<T>) => any)[] = [];
|
|
22
|
+
|
|
23
|
+
constructor(public config: DebounceConfig<T>) {}
|
|
24
|
+
|
|
25
|
+
public get units(): DebounceValue<T>[] {
|
|
26
|
+
return [
|
|
27
|
+
...this._enqueued.map((x) => ({ ...x, state: 'enqueued' as const })),
|
|
28
|
+
...this._processing.map((x) => ({ ...x, state: 'processing' as const })),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public subscribe = (callback: (value: Debounce<T>) => any) => {
|
|
33
|
+
this._subscribers.push(callback);
|
|
34
|
+
return () => {
|
|
35
|
+
this._subscribers = this._subscribers.filter((x) => x !== callback);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
public notify = () => {
|
|
40
|
+
this._subscribers.forEach((subscriber) => subscriber(this));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
public push(value: T) {
|
|
44
|
+
const group = this.config.groupBy(value);
|
|
45
|
+
const unit = this._enqueued.find((unit) => this.config.groupBy(unit.value) === group);
|
|
46
|
+
|
|
47
|
+
if (!unit) {
|
|
48
|
+
this._enqueued.push({ value, enqueueTime: Date.now() });
|
|
49
|
+
} else if (this.config.compare(unit.value, value) >= 0) {
|
|
50
|
+
unit.value = value;
|
|
51
|
+
unit.enqueueTime = Date.now();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this._process(group);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private _process(group: string) {
|
|
58
|
+
if (!this._enqueued.some((unit) => this.config.groupBy(unit.value) === group)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let timeout = this._timeoutByGroup[group];
|
|
63
|
+
timeout && clearTimeout(timeout);
|
|
64
|
+
|
|
65
|
+
if (this._processing.some((unit) => this.config.groupBy(unit.value) === group)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
timeout = setTimeout(() => {
|
|
70
|
+
const processing = this._enqueued.find((unit) => this.config.groupBy(unit.value) === group)!;
|
|
71
|
+
this._processing.push(processing);
|
|
72
|
+
this._enqueued.splice(this._enqueued.indexOf(processing), 1);
|
|
73
|
+
this.notify();
|
|
74
|
+
|
|
75
|
+
this.config
|
|
76
|
+
.callback(processing.value)
|
|
77
|
+
.then(() => {
|
|
78
|
+
this._processing.splice(this._processing.indexOf(processing), 1);
|
|
79
|
+
this.notify();
|
|
80
|
+
this._process(group);
|
|
81
|
+
})
|
|
82
|
+
.catch(() => {
|
|
83
|
+
this._processing.splice(this._processing.indexOf(processing), 1);
|
|
84
|
+
this.push(processing.value);
|
|
85
|
+
});
|
|
86
|
+
}, this.config.timeout);
|
|
87
|
+
|
|
88
|
+
this._timeoutByGroup[group] = timeout;
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './types';
|
|
3
|
-
export * from './api';
|
|
4
|
-
export * from './client';
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './api';
|
|
4
|
+
export * from './client';
|
package/src/core/types.tsx
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
export interface Optional<TValue> {
|
|
2
|
-
hasValue: boolean;
|
|
3
|
-
value?: TValue | null;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface File {
|
|
7
|
-
name: string;
|
|
8
|
-
bytes: number;
|
|
9
|
-
ref: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface Period {
|
|
13
|
-
start: string;
|
|
14
|
-
end: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AutoReply {
|
|
18
|
-
text: string;
|
|
19
|
-
period: Period;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface Account {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
avatar: string;
|
|
26
|
-
autoReply: AutoReply | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface UpdateAccountRequest {
|
|
30
|
-
id: string;
|
|
31
|
-
autoReply?: Optional<AutoReply> | null;
|
|
32
|
-
name?: Optional<string> | null;
|
|
33
|
-
avatar?: Optional<string> | null;
|
|
34
|
-
active?: Optional<boolean> | null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface MessageBase {
|
|
38
|
-
id: string;
|
|
39
|
-
text: string | null;
|
|
40
|
-
files: File[];
|
|
41
|
-
sentAt: string;
|
|
42
|
-
sentBy: Account;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ChatMessage extends MessageBase {
|
|
46
|
-
chatId: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface Chat {
|
|
50
|
-
id: string;
|
|
51
|
-
name: string;
|
|
52
|
-
members: Account[];
|
|
53
|
-
active: boolean;
|
|
54
|
-
lastReadMessageId: string | null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ChatListItem {
|
|
58
|
-
id: string;
|
|
59
|
-
name: string;
|
|
60
|
-
message: ChatMessage;
|
|
61
|
-
totalUnreadCount: number;
|
|
62
|
-
active: boolean;
|
|
63
|
-
lastReadMessageId: string | null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface SendChatMessageRequest {
|
|
67
|
-
chatId: string;
|
|
68
|
-
text: string | null;
|
|
69
|
-
files: File[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface MessageBody {
|
|
73
|
-
text: string | null;
|
|
74
|
-
files: File[];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface AddChatRequest {
|
|
78
|
-
name: string;
|
|
79
|
-
message?: MessageBody;
|
|
80
|
-
members: string[];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface ReadChatMessageRequest {
|
|
84
|
-
id: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface ReadChatMessageEvent {
|
|
88
|
-
chatId: string;
|
|
89
|
-
newLastReadMessageId: string;
|
|
90
|
-
readCount: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface RemoveChatMemberRequest {
|
|
94
|
-
chatId: string;
|
|
95
|
-
accountId: string;
|
|
96
|
-
deleteHistory: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface AddChatMemberRequest {
|
|
100
|
-
chatId: string;
|
|
101
|
-
accountId: string;
|
|
102
|
-
withHistory: boolean;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface UpdateChatNameRequest {
|
|
106
|
-
id: string;
|
|
107
|
-
name: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function chatId(messageId: string) {
|
|
111
|
-
return messageId.slice(0, 36);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function messageSequencePart(id: string) {
|
|
115
|
-
return id.slice(37);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface ThreadWatchListItem {
|
|
119
|
-
id: string;
|
|
120
|
-
name: string;
|
|
121
|
-
createdById: string;
|
|
122
|
-
createdAt: string;
|
|
123
|
-
archive: boolean;
|
|
124
|
-
lastMessage: ThreadMessage | null;
|
|
125
|
-
lastReadMessageId: string | null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface Thread {
|
|
129
|
-
id: string;
|
|
130
|
-
name: string;
|
|
131
|
-
createdBy: Account;
|
|
132
|
-
createdAt: string;
|
|
133
|
-
archive: boolean;
|
|
134
|
-
lastMessageId: string | null;
|
|
135
|
-
lastReadMessageId: string | null;
|
|
136
|
-
watch: boolean;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface ThreadMessage extends MessageBase {
|
|
140
|
-
threadId: string;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export interface SendThreadMessageRequest {
|
|
144
|
-
threadId: string;
|
|
145
|
-
body: MessageBody;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export interface ListSegment<T> {
|
|
149
|
-
items: T[];
|
|
150
|
-
total: number;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export type SystemMessageText =
|
|
154
|
-
| 'chatify://chat-created'
|
|
155
|
-
| 'chatify://member-added'
|
|
156
|
-
| 'chatify://member-removed'
|
|
157
|
-
| `chatify://chat-name-changed`;
|
|
158
|
-
|
|
159
|
-
export function parseThreadMessageId(messageId: string) {
|
|
160
|
-
const [threadId, index] = messageId.split('::', 2);
|
|
161
|
-
return [threadId, parseInt(index, 10)] as const;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function calcThreadUnreadCount(
|
|
165
|
-
thread: Pick<ThreadWatchListItem, 'lastMessage' | 'lastReadMessageId'>,
|
|
166
|
-
) {
|
|
167
|
-
const lastReadMessageIndex =
|
|
168
|
-
thread.lastReadMessageId != null ? parseThreadMessageId(thread.lastReadMessageId)[1] : -1;
|
|
169
|
-
|
|
170
|
-
const lastThreadMessageIndex =
|
|
171
|
-
thread.lastMessage?.id != null ? parseThreadMessageId(thread.lastMessage?.id)[1] : -1;
|
|
172
|
-
|
|
173
|
-
return lastThreadMessageIndex - lastReadMessageIndex;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function calcThreadListUnreadCount(
|
|
177
|
-
threads: Pick<ThreadWatchListItem, 'lastMessage' | 'lastReadMessageId'>[],
|
|
178
|
-
) {
|
|
179
|
-
return threads.reduce((prev, thread) => {
|
|
180
|
-
return prev + calcThreadUnreadCount(thread);
|
|
181
|
-
}, 0);
|
|
182
|
-
}
|
|
1
|
+
export interface Optional<TValue> {
|
|
2
|
+
hasValue: boolean;
|
|
3
|
+
value?: TValue | null;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface File {
|
|
7
|
+
name: string;
|
|
8
|
+
bytes: number;
|
|
9
|
+
ref: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Period {
|
|
13
|
+
start: string;
|
|
14
|
+
end: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AutoReply {
|
|
18
|
+
text: string;
|
|
19
|
+
period: Period;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Account {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
avatar: string;
|
|
26
|
+
autoReply: AutoReply | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UpdateAccountRequest {
|
|
30
|
+
id: string;
|
|
31
|
+
autoReply?: Optional<AutoReply> | null;
|
|
32
|
+
name?: Optional<string> | null;
|
|
33
|
+
avatar?: Optional<string> | null;
|
|
34
|
+
active?: Optional<boolean> | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface MessageBase {
|
|
38
|
+
id: string;
|
|
39
|
+
text: string | null;
|
|
40
|
+
files: File[];
|
|
41
|
+
sentAt: string;
|
|
42
|
+
sentBy: Account;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ChatMessage extends MessageBase {
|
|
46
|
+
chatId: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface Chat {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
members: Account[];
|
|
53
|
+
active: boolean;
|
|
54
|
+
lastReadMessageId: string | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ChatListItem {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
message: ChatMessage;
|
|
61
|
+
totalUnreadCount: number;
|
|
62
|
+
active: boolean;
|
|
63
|
+
lastReadMessageId: string | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface SendChatMessageRequest {
|
|
67
|
+
chatId: string;
|
|
68
|
+
text: string | null;
|
|
69
|
+
files: File[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface MessageBody {
|
|
73
|
+
text: string | null;
|
|
74
|
+
files: File[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface AddChatRequest {
|
|
78
|
+
name: string;
|
|
79
|
+
message?: MessageBody;
|
|
80
|
+
members: string[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ReadChatMessageRequest {
|
|
84
|
+
id: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ReadChatMessageEvent {
|
|
88
|
+
chatId: string;
|
|
89
|
+
newLastReadMessageId: string;
|
|
90
|
+
readCount: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface RemoveChatMemberRequest {
|
|
94
|
+
chatId: string;
|
|
95
|
+
accountId: string;
|
|
96
|
+
deleteHistory: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface AddChatMemberRequest {
|
|
100
|
+
chatId: string;
|
|
101
|
+
accountId: string;
|
|
102
|
+
withHistory: boolean;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface UpdateChatNameRequest {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function chatId(messageId: string) {
|
|
111
|
+
return messageId.slice(0, 36);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function messageSequencePart(id: string) {
|
|
115
|
+
return id.slice(37);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ThreadWatchListItem {
|
|
119
|
+
id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
createdById: string;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
archive: boolean;
|
|
124
|
+
lastMessage: ThreadMessage | null;
|
|
125
|
+
lastReadMessageId: string | null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface Thread {
|
|
129
|
+
id: string;
|
|
130
|
+
name: string;
|
|
131
|
+
createdBy: Account;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
archive: boolean;
|
|
134
|
+
lastMessageId: string | null;
|
|
135
|
+
lastReadMessageId: string | null;
|
|
136
|
+
watch: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ThreadMessage extends MessageBase {
|
|
140
|
+
threadId: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface SendThreadMessageRequest {
|
|
144
|
+
threadId: string;
|
|
145
|
+
body: MessageBody;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ListSegment<T> {
|
|
149
|
+
items: T[];
|
|
150
|
+
total: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type SystemMessageText =
|
|
154
|
+
| 'chatify://chat-created'
|
|
155
|
+
| 'chatify://member-added'
|
|
156
|
+
| 'chatify://member-removed'
|
|
157
|
+
| `chatify://chat-name-changed`;
|
|
158
|
+
|
|
159
|
+
export function parseThreadMessageId(messageId: string) {
|
|
160
|
+
const [threadId, index] = messageId.split('::', 2);
|
|
161
|
+
return [threadId, parseInt(index, 10)] as const;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function calcThreadUnreadCount(
|
|
165
|
+
thread: Pick<ThreadWatchListItem, 'lastMessage' | 'lastReadMessageId'>,
|
|
166
|
+
) {
|
|
167
|
+
const lastReadMessageIndex =
|
|
168
|
+
thread.lastReadMessageId != null ? parseThreadMessageId(thread.lastReadMessageId)[1] : -1;
|
|
169
|
+
|
|
170
|
+
const lastThreadMessageIndex =
|
|
171
|
+
thread.lastMessage?.id != null ? parseThreadMessageId(thread.lastMessage?.id)[1] : -1;
|
|
172
|
+
|
|
173
|
+
return lastThreadMessageIndex - lastReadMessageIndex;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function calcThreadListUnreadCount(
|
|
177
|
+
threads: Pick<ThreadWatchListItem, 'lastMessage' | 'lastReadMessageId'>[],
|
|
178
|
+
) {
|
|
179
|
+
return threads.reduce((prev, thread) => {
|
|
180
|
+
return prev + calcThreadUnreadCount(thread);
|
|
181
|
+
}, 0);
|
|
182
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ui';
|
|
2
|
-
export * from './core';
|
|
1
|
+
export * from './ui';
|
|
2
|
+
export * from './core';
|
package/src/styles/aside.scss
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
@use './variables.scss' as vars;
|
|
2
|
-
@use './mixins.scss' as mixins;
|
|
3
|
-
|
|
4
|
-
.wxchtf-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
@use './variables.scss' as vars;
|
|
2
|
+
@use './mixins.scss' as mixins;
|
|
3
|
+
|
|
4
|
+
.wxchtf-chat-group.--compact {
|
|
5
|
+
.wxchtf-aside {
|
|
6
|
+
width: 100%;
|
|
7
|
+
border-top-right-radius: vars.$radius;
|
|
8
|
+
border-bottom-right-radius: vars.$radius;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.wxchtf-aside {
|
|
13
|
+
flex: none;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-flow: column nowrap;
|
|
16
|
+
background: #ffffff;
|
|
17
|
+
border-top-left-radius: vars.$radius;
|
|
18
|
+
border-bottom-left-radius: vars.$radius;
|
|
19
|
+
padding-top: 15px;
|
|
20
|
+
width: 320px;
|
|
21
|
+
position: relative;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
|
|
24
|
+
&::before {
|
|
25
|
+
position: absolute;
|
|
26
|
+
content: '';
|
|
27
|
+
left: 0;
|
|
28
|
+
bottom: 0;
|
|
29
|
+
width: calc(100% - 10px);
|
|
30
|
+
height: 20px;
|
|
31
|
+
z-index: 1;
|
|
32
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 100%);
|
|
33
|
+
}
|
|
34
|
+
}
|