홈, 갤러리, 캐시 설정, 썸네일 설정 페이지에서의 네트워크 호출 최적화

This commit is contained in:
static
2026-01-01 23:31:01 +09:00
parent 841c57e8fc
commit d98be331ad
10 changed files with 267 additions and 36 deletions

View File

@@ -4,7 +4,7 @@
import { TopBar } from "$lib/components/molecules";
import type { FileCacheIndex } from "$lib/indexedDB";
import { getFileCacheIndex, deleteFileCache as doDeleteFileCache } from "$lib/modules/file";
import { getFileInfo, type MaybeFileInfo } from "$lib/modules/filesystem";
import { bulkGetFileInfo, type MaybeFileInfo } from "$lib/modules/filesystem";
import { masterKeyStore } from "$lib/stores";
import { formatFileSize } from "$lib/utils";
import File from "./File.svelte";
@@ -23,13 +23,17 @@
};
onMount(async () => {
fileCache = await Promise.all(
getFileCacheIndex().map(async (index) => ({
index,
info: await getFileInfo(index.fileId, $masterKeyStore?.get(1)?.key!),
})),
const indexes = getFileCacheIndex();
const infos = await bulkGetFileInfo(
indexes.map(({ fileId }) => fileId),
$masterKeyStore?.get(1)?.key!,
);
fileCache.sort((a, b) => a.index.lastRetrievedAt.getTime() - b.index.lastRetrievedAt.getTime());
fileCache = indexes
.map((index, i) => ({
index,
info: infos.get(index.fileId)!,
}))
.sort((a, b) => a.index.lastRetrievedAt.getTime() - b.index.lastRetrievedAt.getTime());
});
$effect(() => {