perf(*): bound list queries, batch fetches, harden media downloads
This commit is contained in:
1 parent
9c12628304
commit
1fa4f18a9b
35 files changed
+473
-138
No files matched your search
@@ -1,4 +1,10 @@
|
||||
import { enrichChat, getChat, getJob, listChats } from "$lib/api/endpoints";
|
||||
import {
|
||||
enrichChat,
|
||||
getChat,
|
||||
getChatsBatch,
|
||||
getJob,
|
||||
listChats,
|
||||
} from "$lib/api/endpoints";
|
||||
import type { Chat, LiveEvent } from "$lib/api/types";
|
||||
import { folderContains } from "$lib/format/folders";
|
||||
import { accounts } from "$lib/stores/accounts.svelte";
|
||||
@@ -245,6 +251,32 @@ function createChats() {
|
||||
})
|
||||
.catch(() => resolving.delete(id));
|
||||
},
|
||||
ensureMany(ids: number[]) {
|
||||
syncAccount();
|
||||
if (account === null) {
|
||||
return;
|
||||
}
|
||||
const missing = [
|
||||
...new Set(ids.filter((id) => !(resolving.has(id) || known(id)))),
|
||||
];
|
||||
if (missing.length === 0) {
|
||||
return;
|
||||
}
|
||||
for (const id of missing) {
|
||||
resolving.add(id);
|
||||
}
|
||||
getChatsBatch(missing)
|
||||
.then((fetched) => {
|
||||
for (const chat of fetched) {
|
||||
extra[chat.chat_id] = chat;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
for (const id of missing) {
|
||||
resolving.delete(id);
|
||||
}
|
||||
});
|
||||
},
|
||||
load(folderId: number | null = folders.selectedId) {
|
||||
return load(folderId, false);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user