Fix last updated sort
This commit is contained in:
parent
52affeb83f
commit
83fd00c16e
|
@ -18,7 +18,6 @@
|
|||
const onStateChange = (...args:any) => {
|
||||
sortOption = getChatSortOption()
|
||||
sortedChats = $chatsStorage.sort(sortOption.sortFn)
|
||||
// console.log('Sorting', sortOption, sortedChats)
|
||||
}
|
||||
|
||||
$: onStateChange($checkStateChange)
|
||||
|
@ -44,7 +43,9 @@
|
|||
{:else}
|
||||
{#key $checkStateChange}
|
||||
{#each sortedChats as chat, i}
|
||||
{#key chat.id}
|
||||
<ChatMenuItem activeChatId={activeChatId} chat={chat} prevChat={sortedChats[i - 1]} nextChat={sortedChats[i + 1]} />
|
||||
{/key}
|
||||
{/each}
|
||||
{/key}
|
||||
{/if}
|
||||
|
|
|
@ -243,6 +243,15 @@
|
|||
}, 10)
|
||||
}
|
||||
|
||||
const signalChangeTimers: any = {}
|
||||
const setChatLastUse = (chatId: number, time: number) => {
|
||||
clearTimeout(signalChangeTimers[chatId])
|
||||
signalChangeTimers[chatId] = setTimeout(() => {
|
||||
getChat(chatId).lastUse = time
|
||||
saveChatStore()
|
||||
}, 500)
|
||||
}
|
||||
|
||||
const setMessagesTimers: any = {}
|
||||
export const setMessages = (chatId: number, messages: Message[]) => {
|
||||
if (get(currentChatId) === chatId) {
|
||||
|
@ -253,13 +262,13 @@
|
|||
setMessagesTimers[chatId] = setTimeout(() => {
|
||||
getChat(chatId).messages = messages
|
||||
saveChatStore()
|
||||
setChatLastUse(chatId, Date.now())
|
||||
}, 200)
|
||||
} else {
|
||||
clearTimeout(setMessagesTimers[chatId])
|
||||
const chat = getChat(chatId)
|
||||
chat.lastUse = Date.now()
|
||||
chat.messages = messages
|
||||
getChat(chatId).messages = messages
|
||||
saveChatStore()
|
||||
setChatLastUse(chatId, Date.now())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue