사소한 리팩토링 2

This commit is contained in:
static
2025-07-08 02:26:51 +09:00
parent 9b1e27c20b
commit a42ec28176
3 changed files with 6 additions and 7 deletions

View File

@@ -110,7 +110,7 @@ const encryptFile = limitFunction(
const thumbnail = await generateThumbnail(fileBuffer, fileType);
const thumbnailBuffer = await thumbnail?.arrayBuffer();
const thumbnailEncrypted = thumbnailBuffer ? await encryptData(thumbnailBuffer, dataKey) : null;
const thumbnailEncrypted = thumbnailBuffer && (await encryptData(thumbnailBuffer, dataKey));
status.update((value) => {
value.status = "upload-pending";
@@ -126,8 +126,7 @@ const encryptFile = limitFunction(
nameEncrypted,
createdAtEncrypted,
lastModifiedAtEncrypted,
thumbnail: thumbnail &&
thumbnailEncrypted && { plaintext: thumbnailBuffer, ...thumbnailEncrypted },
thumbnail: thumbnailEncrypted && { plaintext: thumbnailBuffer, ...thumbnailEncrypted },
};
},
{ concurrency: 4 },

View File

@@ -43,7 +43,7 @@
<TopBar title="썸네일" />
<FullscreenDiv class="bg-gray-100 !px-0">
<div class="flex flex-grow flex-col space-y-4">
<div class="flex-shrink-0 bg-white p-4 !pt-0">
<div class="bg-white p-4 !pt-0">
<IconEntryButton icon={IconDelete} onclick={deleteAllFileThumbnailCaches} class="w-full">
저장된 썸네일 모두 삭제하기
</IconEntryButton>
@@ -70,7 +70,7 @@
{/if}
</div>
{#if persistentStates.files.length > 0}
<BottomDiv class="flex flex-col items-center gap-y-2 px-4">
<BottomDiv class="px-4">
<Button onclick={generateAllThumbnails} class="w-full">모두 썸네일 생성하기</Button>
</BottomDiv>
{/if}

View File

@@ -27,7 +27,7 @@ export const persistentStates = $state({
files: [] as File[],
});
export const getGenerationStatus = (fileId: number): Writable<GenerationStatus> | undefined => {
export const getGenerationStatus = (fileId: number) => {
return workingFiles.get(fileId);
};
@@ -39,6 +39,7 @@ const generateThumbnail = limitFunction(
dataKey: CryptoKey,
) => {
status.set("generating");
const thumbnail = await doGenerateThumbnail(fileBuffer, fileType);
if (!thumbnail) {
status.set("error");
@@ -47,7 +48,6 @@ const generateThumbnail = limitFunction(
const thumbnailBuffer = await thumbnail.arrayBuffer();
const thumbnailEncrypted = await encryptData(thumbnailBuffer, dataKey);
status.set("upload-pending");
return { plaintext: thumbnailBuffer, ...thumbnailEncrypted };
},