p0: harden realtime reconciliation and revoke-all token invalidation
All checks were successful
CI / test (push) Successful in 23s

This commit is contained in:
2026-03-08 14:04:11 +03:00
parent a9106b7fa3
commit 9b3b404993
7 changed files with 86 additions and 7 deletions

View File

@@ -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);
}
}