feat(realtime): add voice/video recording activity events
Some checks are pending
CI / test (push) Has started running
Some checks are pending
CI / test (push) Has started running
This commit is contained in:
@@ -61,6 +61,8 @@ interface ChatState {
|
||||
hasMoreByChat: Record<number, boolean>;
|
||||
loadingMoreByChat: Record<number, boolean>;
|
||||
typingByChat: Record<number, number[]>;
|
||||
recordingVoiceByChat: Record<number, number[]>;
|
||||
recordingVideoByChat: Record<number, number[]>;
|
||||
replyToByChat: Record<number, Message | null>;
|
||||
editingByChat: Record<number, Message | null>;
|
||||
unreadBoundaryByChat: Record<number, number>;
|
||||
@@ -93,6 +95,7 @@ interface ChatState {
|
||||
incrementUnread: (chatId: number, hasMention?: boolean) => void;
|
||||
clearUnread: (chatId: number) => void;
|
||||
setTypingUsers: (chatId: number, userIds: number[]) => void;
|
||||
setRecordingUsers: (chatId: number, kind: "voice" | "video", userIds: number[]) => void;
|
||||
setReplyToMessage: (chatId: number, message: Message | null) => void;
|
||||
setEditingMessage: (chatId: number, message: Message | null) => void;
|
||||
updateChatPinnedMessage: (chatId: number, pinnedMessageId: number | null) => void;
|
||||
@@ -111,6 +114,8 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
||||
hasMoreByChat: {},
|
||||
loadingMoreByChat: {},
|
||||
typingByChat: {},
|
||||
recordingVoiceByChat: {},
|
||||
recordingVideoByChat: {},
|
||||
replyToByChat: {},
|
||||
editingByChat: {},
|
||||
unreadBoundaryByChat: {},
|
||||
@@ -397,6 +402,12 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
||||
})),
|
||||
setTypingUsers: (chatId, userIds) =>
|
||||
set((state) => ({ typingByChat: { ...state.typingByChat, [chatId]: userIds } })),
|
||||
setRecordingUsers: (chatId, kind, userIds) =>
|
||||
set((state) =>
|
||||
kind === "voice"
|
||||
? { recordingVoiceByChat: { ...state.recordingVoiceByChat, [chatId]: userIds } }
|
||||
: { recordingVideoByChat: { ...state.recordingVideoByChat, [chatId]: userIds } }
|
||||
),
|
||||
setReplyToMessage: (chatId, message) =>
|
||||
set((state) => ({ replyToByChat: { ...state.replyToByChat, [chatId]: message } })),
|
||||
setEditingMessage: (chatId, message) =>
|
||||
@@ -438,6 +449,8 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
||||
const nextHasMoreByChat = { ...state.hasMoreByChat };
|
||||
const nextLoadingMoreByChat = { ...state.loadingMoreByChat };
|
||||
const nextTypingByChat = { ...state.typingByChat };
|
||||
const nextRecordingVoiceByChat = { ...state.recordingVoiceByChat };
|
||||
const nextRecordingVideoByChat = { ...state.recordingVideoByChat };
|
||||
const nextReplyToByChat = { ...state.replyToByChat };
|
||||
const nextEditingByChat = { ...state.editingByChat };
|
||||
const nextUnreadBoundaryByChat = { ...state.unreadBoundaryByChat };
|
||||
@@ -447,6 +460,8 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
||||
delete nextHasMoreByChat[chatId];
|
||||
delete nextLoadingMoreByChat[chatId];
|
||||
delete nextTypingByChat[chatId];
|
||||
delete nextRecordingVoiceByChat[chatId];
|
||||
delete nextRecordingVideoByChat[chatId];
|
||||
delete nextReplyToByChat[chatId];
|
||||
delete nextEditingByChat[chatId];
|
||||
delete nextUnreadBoundaryByChat[chatId];
|
||||
@@ -461,6 +476,8 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
||||
hasMoreByChat: nextHasMoreByChat,
|
||||
loadingMoreByChat: nextLoadingMoreByChat,
|
||||
typingByChat: nextTypingByChat,
|
||||
recordingVoiceByChat: nextRecordingVoiceByChat,
|
||||
recordingVideoByChat: nextRecordingVideoByChat,
|
||||
replyToByChat: nextReplyToByChat,
|
||||
editingByChat: nextEditingByChat,
|
||||
unreadBoundaryByChat: nextUnreadBoundaryByChat,
|
||||
|
||||
Reference in New Issue
Block a user