mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 15:08:46 +00:00
사소한 리팩토링 2
This commit is contained in:
22
src/lib/components/organisms/modals/ForceLoginModal.svelte
Normal file
22
src/lib/components/organisms/modals/ForceLoginModal.svelte
Normal file
@@ -0,0 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { ActionModal } from "$lib/components/molecules";
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
oncancel?: () => void;
|
||||
onLoginClick: () => void;
|
||||
}
|
||||
|
||||
let { isOpen = $bindable(), oncancel, onLoginClick }: Props = $props();
|
||||
</script>
|
||||
|
||||
<ActionModal
|
||||
bind:isOpen
|
||||
title="다른 디바이스에 이미 로그인되어 있어요."
|
||||
cancelText="아니요"
|
||||
{oncancel}
|
||||
confirmText="네"
|
||||
onConfirmClick={onLoginClick}
|
||||
>
|
||||
<p>다른 디바이스에서는 로그아웃하고, 이 디바이스에서 로그인할까요?</p>
|
||||
</ActionModal>
|
||||
@@ -1,3 +1,4 @@
|
||||
export { default as CategoryCreateModal } from "./CategoryCreateModal.svelte";
|
||||
export { default as ForceLoginModal } from "./ForceLoginModal.svelte";
|
||||
export { default as RenameModal } from "./RenameModal.svelte";
|
||||
export { default as TextInputModal } from "./TextInputModal.svelte";
|
||||
|
||||
@@ -11,7 +11,11 @@ import {
|
||||
downloadFile,
|
||||
} from "$lib/modules/file";
|
||||
import { getThumbnailUrl } from "$lib/modules/thumbnail";
|
||||
import type { FileThumbnailInfoResponse, FileListResponse } from "$lib/server/schemas";
|
||||
import type {
|
||||
FileThumbnailInfoResponse,
|
||||
FileThumbnailUploadRequest,
|
||||
FileListResponse,
|
||||
} from "$lib/server/schemas";
|
||||
|
||||
export const requestFileDownload = async (
|
||||
fileId: number,
|
||||
@@ -26,6 +30,24 @@ export const requestFileDownload = async (
|
||||
return fileBuffer;
|
||||
};
|
||||
|
||||
export const requestFileThumbnailUpload = async (
|
||||
fileId: number,
|
||||
dataKeyVersion: Date,
|
||||
thumbnailEncrypted: { ciphertext: ArrayBuffer; iv: string },
|
||||
) => {
|
||||
const form = new FormData();
|
||||
form.set(
|
||||
"metadata",
|
||||
JSON.stringify({
|
||||
dekVersion: dataKeyVersion.toISOString(),
|
||||
contentIv: thumbnailEncrypted.iv,
|
||||
} satisfies FileThumbnailUploadRequest),
|
||||
);
|
||||
form.set("content", new Blob([thumbnailEncrypted.ciphertext]));
|
||||
|
||||
return await fetch(`/api/file/${fileId}/thumbnail/upload`, { method: "POST", body: form });
|
||||
};
|
||||
|
||||
export const requestFileThumbnailDownload = async (fileId: number, dataKey: CryptoKey) => {
|
||||
const cache = await getFileThumbnailCache(fileId);
|
||||
if (cache) return cache;
|
||||
|
||||
Reference in New Issue
Block a user