From f34764ffe02edd03d70967b29aa232bdc834dd69 Mon Sep 17 00:00:00 2001 From: static Date: Wed, 22 Jan 2025 22:24:44 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=97=90=EC=84=9C=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EC=9E=AC=EA=B7=80=EC=A0=81?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=ED=91=9C=EC=8B=9C=ED=95=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/components/inputs/CheckBox.svelte | 23 ++++++++ src/lib/components/inputs/index.ts | 1 + src/lib/modules/filesystem.ts | 6 +- src/lib/organisms/Category/Category.svelte | 15 ++++- src/lib/server/db/file.ts | 56 ++++++++++--------- src/lib/server/schemas/category.ts | 7 ++- src/lib/server/services/category.ts | 6 +- .../(main)/category/[[id]]/+page.svelte | 3 + .../api/category/[id]/file/list/+server.ts | 22 ++++++-- 9 files changed, 98 insertions(+), 41 deletions(-) create mode 100644 src/lib/components/inputs/CheckBox.svelte diff --git a/src/lib/components/inputs/CheckBox.svelte b/src/lib/components/inputs/CheckBox.svelte new file mode 100644 index 0000000..813a7e0 --- /dev/null +++ b/src/lib/components/inputs/CheckBox.svelte @@ -0,0 +1,23 @@ + + + diff --git a/src/lib/components/inputs/index.ts b/src/lib/components/inputs/index.ts index c2c534d..47cb929 100644 --- a/src/lib/components/inputs/index.ts +++ b/src/lib/components/inputs/index.ts @@ -1 +1,2 @@ +export { default as CheckBox } from "./CheckBox.svelte"; export { default as TextInput } from "./TextInput.svelte"; diff --git a/src/lib/modules/filesystem.ts b/src/lib/modules/filesystem.ts index f098456..0e786ce 100644 --- a/src/lib/modules/filesystem.ts +++ b/src/lib/modules/filesystem.ts @@ -66,7 +66,7 @@ export type CategoryInfo = dataKeyVersion?: Date; name: string; subCategoryIds: number[]; - files: number[]; + files: { id: number; isRecursive: boolean }[]; }; const directoryInfoStore = new Map>(); @@ -256,7 +256,7 @@ const fetchCategoryInfoFromServer = async ( const { dataKey } = await unwrapDataKey(metadata!.dek, masterKey); const name = await decryptString(metadata!.name, metadata!.nameIv, dataKey); - res = await callGetApi(`/api/category/${id}/file/list`); + res = await callGetApi(`/api/category/${id}/file/list?recursive=true`); if (!res.ok) { throw new Error("Failed to fetch category files"); } @@ -269,7 +269,7 @@ const fetchCategoryInfoFromServer = async ( dataKeyVersion: new Date(metadata!.dekVersion), name, subCategoryIds: subCategories, - files, + files: files.map(({ file, isRecursive }) => ({ id: file, isRecursive })), }); } }; diff --git a/src/lib/organisms/Category/Category.svelte b/src/lib/organisms/Category/Category.svelte index d70a6d3..563293d 100644 --- a/src/lib/organisms/Category/Category.svelte +++ b/src/lib/organisms/Category/Category.svelte @@ -1,5 +1,6 @@