디렉터리 페이지에서의 네트워크 호출 최적화

This commit is contained in:
static
2025-12-30 17:21:54 +09:00
parent cdb652cacf
commit 409ae09f4f
25 changed files with 507 additions and 560 deletions

View File

@@ -14,8 +14,7 @@ import { trpc } from "$trpc/client";
export interface SelectedEntry {
type: "directory" | "file";
id: number;
dataKey: CryptoKey;
dataKeyVersion: Date;
dataKey: { key: CryptoKey; version: Date } | undefined;
name: string;
}
@@ -97,20 +96,26 @@ export const requestFileUpload = async (
};
export const requestEntryRename = async (entry: SelectedEntry, newName: string) => {
const newNameEncrypted = await encryptString(newName, entry.dataKey);
if (!entry.dataKey) {
// TODO: Error Handling
console.log("hi");
return false;
}
const newNameEncrypted = await encryptString(newName, entry.dataKey.key);
try {
if (entry.type === "directory") {
await trpc().directory.rename.mutate({
id: entry.id,
dekVersion: entry.dataKeyVersion,
dekVersion: entry.dataKey.version,
name: newNameEncrypted.ciphertext,
nameIv: newNameEncrypted.iv,
});
} else {
await trpc().file.rename.mutate({
id: entry.id,
dekVersion: entry.dataKeyVersion,
dekVersion: entry.dataKey.version,
name: newNameEncrypted.ciphertext,
nameIv: newNameEncrypted.iv,
});