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
@@ -2,7 +2,7 @@
|
||||
import { untrack } from "svelte";
|
||||
import {
|
||||
enqueueStoriesBackfill,
|
||||
getChat,
|
||||
getChatsBatch,
|
||||
getPeers,
|
||||
getStories,
|
||||
} from "$lib/api/endpoints";
|
||||
@@ -63,17 +63,13 @@
|
||||
const chatIds = [...byPeer.keys()].filter((id) => id < 0);
|
||||
const [peers, fetched] = await Promise.all([
|
||||
getPeers(peerIds),
|
||||
Promise.all(chatIds.map((id) => getChat(id))),
|
||||
getChatsBatch(chatIds),
|
||||
]);
|
||||
if (current !== token) {
|
||||
return;
|
||||
}
|
||||
const peerById = new Map(peers.map((peer) => [peer.peer_id, peer]));
|
||||
const chatById = new Map(
|
||||
fetched
|
||||
.filter((item) => item !== null)
|
||||
.map((item) => [item.chat_id, item])
|
||||
);
|
||||
const chatById = new Map(fetched.map((item) => [item.chat_id, item]));
|
||||
groups = [...byPeer.entries()].map(([peerId, stories]) => {
|
||||
if (peerId > 0) {
|
||||
const peer = peerById.get(peerId) ?? null;
|
||||
|
||||
Reference in new issue
Block a user