Mask UI blocking when loading large chat session

This commit is contained in:
Webifi
2023-06-16 10:35:35 -05:00
parent cff9998682
commit ca0627306f
4 changed files with 27 additions and 16 deletions

View File

@@ -222,6 +222,19 @@
return getChat(chatId).messages
}
let setChatTimer: any
export const setCurrentChat = (chatId: number) => {
clearTimeout(setChatTimer)
if (!chatId) {
currentChatId.set(0)
currentChatMessages.set([])
}
setChatTimer = setTimeout(() => {
currentChatId.set(chatId)
currentChatMessages.set(getChat(chatId).messages)
}, 10)
}
let setMessagesTimer: any
export const setMessages = (chatId: number, messages: Message[]) => {
if (get(currentChatId) === chatId) {