perf(*): bound list queries, batch fetches, harden media downloads

This commit is contained in:
hh committed 2026-09-01 21:38:22 +02:00
1 parent 9c12628304
commit 1fa4f18a9b
35 files changed
+473 -138

No files matched your search

@@ -35,6 +35,7 @@
let items = $state<FileShare[]>([]);
let loading = $state(false);
let filter = $state<Filter>("active");
let fetchedAll = $state(false);
let expanded = $state<number | null>(null);
let token = 0;
@@ -44,16 +45,20 @@
: items
);
const activeCount = $derived(
items.filter((item) => shareState(item) === "active").length
fetchedAll
? items.filter((item) => shareState(item) === "active").length
: items.length
);
async function load() {
const current = ++token;
const activeOnly = filter === "active";
loading = true;
try {
const rows = await listShares();
const rows = await listShares(activeOnly);
if (current === token) {
items = rows;
fetchedAll = !activeOnly;
}
} catch {
if (current === token) {
@@ -118,7 +123,7 @@
let loadedKey = "";
$effect(() => {
const key = `${accounts.selectedId}:${shareUi.revision}`;
const key = `${accounts.selectedId}:${shareUi.revision}:${filter}`;
if (accounts.selectedId !== null && key !== loadedKey) {
loadedKey = key;
load();