feat(realtime): add voice/video recording activity events
Some checks are pending
CI / test (push) Has started running

This commit is contained in:
2026-03-08 19:53:48 +03:00
parent 1ef0cdf29d
commit ac82e25d16
8 changed files with 135 additions and 9 deletions

View File

@@ -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,