refac
This commit is contained in:
@@ -137,6 +137,7 @@
|
||||
upsertChat?: (chat: Record<string, unknown>) => unknown;
|
||||
setChatActive?: (chatId: string, active: boolean) => boolean;
|
||||
setChatReadAt?: (chatId: string, lastReadAt: number) => boolean;
|
||||
setAllChatsRead?: () => unknown;
|
||||
}
|
||||
> = {};
|
||||
|
||||
@@ -455,7 +456,13 @@
|
||||
if (!res) return;
|
||||
|
||||
showChatsMenu = false;
|
||||
if (res.folder_unread_counts) {
|
||||
applyFolderUnreadCounts(res.folder_unread_counts);
|
||||
}
|
||||
setAllChatsRead();
|
||||
for (const folder of Object.values(folderRegistry)) {
|
||||
folder?.setAllChatsRead?.();
|
||||
}
|
||||
};
|
||||
|
||||
const importChatHandler = async (items, pinned = false, folderId = null) => {
|
||||
|
||||
@@ -392,6 +392,17 @@
|
||||
return found;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
setAllChatsRead: () => {
|
||||
if (chats) {
|
||||
chats = sortFolderChats(
|
||||
chats.map((chat) =>
|
||||
!chat.user_id || chat.user_id === $user?.id
|
||||
? { ...chat, last_read_at: chat.updated_at }
|
||||
: chat
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (folderElement) {
|
||||
|
||||
Reference in New Issue
Block a user