mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
사소한 리팩토링 2
This commit is contained in:
@@ -92,7 +92,7 @@
|
||||
{#key info}
|
||||
<RowVirtualizer
|
||||
count={files.length}
|
||||
itemHeight={(index) => 56 + (index + 1 < files.length ? 4 : 0)}
|
||||
itemHeight={(index) => 48 + (index + 1 < files.length ? 4 : 0)}
|
||||
>
|
||||
{#snippet item(index)}
|
||||
{@const { info, isRecursive } = files[index]!}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { TRPCClientError } from "@trpc/client";
|
||||
import { get, writable, type Writable } from "svelte/store";
|
||||
import {
|
||||
getDirectoryInfos as getDirectoryInfosFromIndexedDB,
|
||||
@@ -18,7 +17,7 @@ import {
|
||||
type CategoryId,
|
||||
} from "$lib/indexedDB";
|
||||
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
|
||||
import { trpc } from "$trpc/client";
|
||||
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||
|
||||
export type DirectoryInfo =
|
||||
| {
|
||||
@@ -114,7 +113,7 @@ const fetchDirectoryInfoFromServer = async (
|
||||
try {
|
||||
data = await trpc().directory.get.query({ id });
|
||||
} catch (e) {
|
||||
if (e instanceof TRPCClientError && e.data?.code === "NOT_FOUND") {
|
||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||
info.set(null);
|
||||
await deleteDirectoryInfo(id as number);
|
||||
return;
|
||||
@@ -187,7 +186,7 @@ const fetchFileInfoFromServer = async (
|
||||
try {
|
||||
metadata = await trpc().file.get.query({ id });
|
||||
} catch (e) {
|
||||
if (e instanceof TRPCClientError && e.data?.code === "NOT_FOUND") {
|
||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||
info.set(null);
|
||||
await deleteFileInfo(id);
|
||||
return;
|
||||
@@ -283,7 +282,7 @@ const fetchCategoryInfoFromServer = async (
|
||||
try {
|
||||
data = await trpc().category.get.query({ id });
|
||||
} catch (e) {
|
||||
if (e instanceof TRPCClientError && e.data?.code === "NOT_FOUND") {
|
||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||
info.set(null);
|
||||
await deleteCategoryInfo(id as number);
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { TRPCClientError } from "@trpc/client";
|
||||
import { encodeToBase64, decryptChallenge, signMessageRSA } from "$lib/modules/crypto";
|
||||
import { trpc } from "$trpc/client";
|
||||
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||
|
||||
export const requestSessionUpgrade = async (
|
||||
encryptKeyBase64: string,
|
||||
@@ -16,7 +15,7 @@ export const requestSessionUpgrade = async (
|
||||
sigPubKey: verifyKeyBase64,
|
||||
}));
|
||||
} catch (e) {
|
||||
if (e instanceof TRPCClientError && e.data?.code === "FORBIDDEN") {
|
||||
if (isTRPCClientError(e) && e.data?.code === "FORBIDDEN") {
|
||||
return [false, "Unregistered client"] as const;
|
||||
}
|
||||
return [false] as const;
|
||||
@@ -31,7 +30,7 @@ export const requestSessionUpgrade = async (
|
||||
force,
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof TRPCClientError && e.data?.code === "CONFLICT") {
|
||||
if (isTRPCClientError(e) && e.data?.code === "CONFLICT") {
|
||||
return [false, "Already logged in"] as const;
|
||||
}
|
||||
return [false] as const;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { TRPCClientError } from "@trpc/client";
|
||||
import { storeMasterKeys } from "$lib/indexedDB";
|
||||
import {
|
||||
encodeToBase64,
|
||||
@@ -11,7 +10,7 @@ import {
|
||||
} from "$lib/modules/crypto";
|
||||
import { requestSessionUpgrade } from "$lib/services/auth";
|
||||
import { masterKeyStore, type ClientKeys } from "$lib/stores";
|
||||
import { trpc } from "$trpc/client";
|
||||
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||
|
||||
export const requestClientRegistration = async (
|
||||
encryptKeyBase64: string,
|
||||
@@ -112,10 +111,7 @@ export const requestInitialMasterKeyAndHmacSecretRegistration = async (
|
||||
mekSig: await signMasterKeyWrapped(masterKeyWrapped, 1, signKey),
|
||||
});
|
||||
} catch (e) {
|
||||
if (
|
||||
e instanceof TRPCClientError &&
|
||||
(e.data?.code === "FORBIDDEN" || e.data?.code === "CONFLICT")
|
||||
) {
|
||||
if (isTRPCClientError(e) && (e.data?.code === "FORBIDDEN" || e.data?.code === "CONFLICT")) {
|
||||
return true;
|
||||
}
|
||||
// TODO: Error Handling
|
||||
|
||||
Reference in New Issue
Block a user