mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-05 00:26:54 +00:00
파일 페이지에서의 네트워크 호출 최적화
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import type { Writable } from "svelte/store";
|
||||
import { FullscreenDiv } from "$lib/components/atoms";
|
||||
import { TopBar } from "$lib/components/molecules";
|
||||
import type { FileCacheIndex } from "$lib/indexedDB";
|
||||
import { getFileCacheIndex, deleteFileCache as doDeleteFileCache } from "$lib/modules/file";
|
||||
import { getFileInfo, type FileInfo } from "$lib/modules/filesystem";
|
||||
import { getFileInfo, type FileInfo } from "$lib/modules/filesystem2.svelte";
|
||||
import { masterKeyStore } from "$lib/stores";
|
||||
import { formatFileSize } from "$lib/utils";
|
||||
import File from "./File.svelte";
|
||||
|
||||
interface FileCache {
|
||||
index: FileCacheIndex;
|
||||
fileInfo: Writable<FileInfo | null>;
|
||||
fileInfo: FileInfo | null;
|
||||
}
|
||||
|
||||
let fileCache: FileCache[] | undefined = $state();
|
||||
@@ -23,13 +22,14 @@
|
||||
fileCache = fileCache?.filter(({ index }) => index.fileId !== fileId);
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
fileCache = getFileCacheIndex()
|
||||
.map((index) => ({
|
||||
onMount(async () => {
|
||||
fileCache = await Promise.all(
|
||||
getFileCacheIndex().map(async (index) => ({
|
||||
index,
|
||||
fileInfo: getFileInfo(index.fileId, $masterKeyStore?.get(1)?.key!),
|
||||
}))
|
||||
.sort((a, b) => a.index.lastRetrievedAt.getTime() - b.index.lastRetrievedAt.getTime());
|
||||
fileInfo: await getFileInfo(index.fileId, $masterKeyStore?.get(1)?.key!),
|
||||
})),
|
||||
);
|
||||
fileCache.sort((a, b) => a.index.lastRetrievedAt.getTime() - b.index.lastRetrievedAt.getTime());
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { Writable } from "svelte/store";
|
||||
import type { FileCacheIndex } from "$lib/indexedDB";
|
||||
import type { FileInfo } from "$lib/modules/filesystem";
|
||||
import type { SummarizedFileInfo } from "$lib/modules/filesystem2.svelte";
|
||||
import { formatDate, formatFileSize } from "$lib/utils";
|
||||
|
||||
import IconDraft from "~icons/material-symbols/draft";
|
||||
@@ -10,7 +9,7 @@
|
||||
|
||||
interface Props {
|
||||
index: FileCacheIndex;
|
||||
info: Writable<FileInfo | null>;
|
||||
info: SummarizedFileInfo | null;
|
||||
onDeleteClick: (fileId: number) => void;
|
||||
}
|
||||
|
||||
@@ -18,7 +17,7 @@
|
||||
</script>
|
||||
|
||||
<div class="flex h-14 items-center gap-x-4 p-2">
|
||||
{#if $info}
|
||||
{#if info}
|
||||
<div class="flex-shrink-0 rounded-full bg-blue-100 p-1 text-xl">
|
||||
<IconDraft class="text-blue-400" />
|
||||
</div>
|
||||
@@ -28,8 +27,8 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex-grow overflow-hidden">
|
||||
{#if $info}
|
||||
<p title={$info.name} class="truncate font-medium">{$info.name}</p>
|
||||
{#if info}
|
||||
<p title={info.name} class="truncate font-medium">{info.name}</p>
|
||||
{:else}
|
||||
<p class="font-medium">삭제된 파일</p>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user