p0: harden realtime reconciliation and revoke-all token invalidation
All checks were successful
CI / test (push) Successful in 23s
All checks were successful
CI / test (push) Successful in 23s
This commit is contained in:
@@ -134,7 +134,7 @@ export function useRealtime() {
|
||||
const chatId = Number(event.payload.chat_id);
|
||||
if (Number.isFinite(chatId)) {
|
||||
scheduleReloadChats();
|
||||
if (chatStore.activeChatId === chatId) {
|
||||
if (chatStore.activeChatId === chatId || (chatStore.messagesByChat[chatId]?.length ?? 0) > 0) {
|
||||
void chatStore.loadMessages(chatId);
|
||||
}
|
||||
}
|
||||
@@ -282,8 +282,15 @@ export function useRealtime() {
|
||||
const storeBefore = useChatStore.getState();
|
||||
await storeBefore.loadChats();
|
||||
const storeAfter = useChatStore.getState();
|
||||
const loadedChatIds = Object.keys(storeAfter.messagesByChat)
|
||||
.map((value) => Number(value))
|
||||
.filter((value) => Number.isFinite(value) && (storeAfter.messagesByChat[value]?.length ?? 0) > 0);
|
||||
const uniqueChatIds = new Set<number>(loadedChatIds);
|
||||
if (storeAfter.activeChatId) {
|
||||
await storeAfter.loadMessages(storeAfter.activeChatId);
|
||||
uniqueChatIds.add(storeAfter.activeChatId);
|
||||
}
|
||||
for (const chatId of uniqueChatIds) {
|
||||
await storeAfter.loadMessages(chatId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user