사소한 리팩토링 2

This commit is contained in:
static
2025-12-26 15:45:03 +09:00
parent d94d14cf83
commit c9d4b10356
16 changed files with 54 additions and 84 deletions

View File

@@ -1,18 +1,17 @@
import { generateDataKey, wrapDataKey, encryptString } from "$lib/modules/crypto";
import type { MasterKey } from "$lib/stores";
import { useTRPC } from "$trpc/client";
import { trpc } from "$trpc/client";
export const requestCategoryCreation = async (
name: string,
parentId: "root" | number,
masterKey: MasterKey,
) => {
const trpc = useTRPC();
const { dataKey, dataKeyVersion } = await generateDataKey();
const nameEncrypted = await encryptString(name, dataKey);
try {
await trpc.category.create.mutate({
await trpc().category.create.mutate({
parent: parentId,
mekVersion: masterKey.version,
dek: await wrapDataKey(dataKey, masterKey.key),
@@ -28,10 +27,9 @@ export const requestCategoryCreation = async (
};
export const requestFileRemovalFromCategory = async (fileId: number, categoryId: number) => {
const trpc = useTRPC();
try {
await trpc.category.removeFile.mutate({ id: categoryId, file: fileId });
await trpc().category.removeFile.mutate({ id: categoryId, file: fileId });
return true;
} catch {
// TODO: Error Handling