mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 16:16:55 +00:00
Compare commits
2 Commits
174305ca1b
...
cdb652cacf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdb652cacf | ||
|
|
15b6a53710 |
@@ -92,7 +92,7 @@
|
|||||||
{#key info}
|
{#key info}
|
||||||
<RowVirtualizer
|
<RowVirtualizer
|
||||||
count={files.length}
|
count={files.length}
|
||||||
itemHeight={(index) => 56 + (index + 1 < files.length ? 4 : 0)}
|
itemHeight={(index) => 48 + (index + 1 < files.length ? 4 : 0)}
|
||||||
>
|
>
|
||||||
{#snippet item(index)}
|
{#snippet item(index)}
|
||||||
{@const { info, isRecursive } = files[index]!}
|
{@const { info, isRecursive } = files[index]!}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
count={rows.length}
|
count={rows.length}
|
||||||
itemHeight={(index) =>
|
itemHeight={(index) =>
|
||||||
rows[index]!.type === "header"
|
rows[index]!.type === "header"
|
||||||
? 32
|
? 28
|
||||||
: Math.ceil(rows[index]!.items.length / 4) * 181 +
|
: Math.ceil(rows[index]!.items.length / 4) * 181 +
|
||||||
(Math.ceil(rows[index]!.items.length / 4) - 1) * 4 +
|
(Math.ceil(rows[index]!.items.length / 4) - 1) * 4 +
|
||||||
16}
|
16}
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
{#snippet item(index)}
|
{#snippet item(index)}
|
||||||
{@const row = rows[index]!}
|
{@const row = rows[index]!}
|
||||||
{#if row.type === "header"}
|
{#if row.type === "header"}
|
||||||
<p class="pb-2 font-medium">{row.label}</p>
|
<p class="pb-2 text-sm font-medium">{row.label}</p>
|
||||||
{:else}
|
{:else}
|
||||||
<div class={["grid grid-cols-4 gap-x-1", row.isLast ? "pb-4" : "pb-1"]}>
|
<div class={["grid grid-cols-4 gap-x-1", row.isLast ? "pb-4" : "pb-1"]}>
|
||||||
{#each row.items as { info }}
|
{#each row.items as { info }}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { TRPCClientError } from "@trpc/client";
|
|
||||||
import { get, writable, type Writable } from "svelte/store";
|
import { get, writable, type Writable } from "svelte/store";
|
||||||
import {
|
import {
|
||||||
getDirectoryInfos as getDirectoryInfosFromIndexedDB,
|
getDirectoryInfos as getDirectoryInfosFromIndexedDB,
|
||||||
@@ -18,7 +17,7 @@ import {
|
|||||||
type CategoryId,
|
type CategoryId,
|
||||||
} from "$lib/indexedDB";
|
} from "$lib/indexedDB";
|
||||||
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
|
import { unwrapDataKey, decryptString } from "$lib/modules/crypto";
|
||||||
import { trpc } from "$trpc/client";
|
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||||
|
|
||||||
export type DirectoryInfo =
|
export type DirectoryInfo =
|
||||||
| {
|
| {
|
||||||
@@ -114,7 +113,7 @@ const fetchDirectoryInfoFromServer = async (
|
|||||||
try {
|
try {
|
||||||
data = await trpc().directory.get.query({ id });
|
data = await trpc().directory.get.query({ id });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof TRPCClientError && e.data?.code === "NOT_FOUND") {
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
info.set(null);
|
info.set(null);
|
||||||
await deleteDirectoryInfo(id as number);
|
await deleteDirectoryInfo(id as number);
|
||||||
return;
|
return;
|
||||||
@@ -187,7 +186,7 @@ const fetchFileInfoFromServer = async (
|
|||||||
try {
|
try {
|
||||||
metadata = await trpc().file.get.query({ id });
|
metadata = await trpc().file.get.query({ id });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof TRPCClientError && e.data?.code === "NOT_FOUND") {
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
info.set(null);
|
info.set(null);
|
||||||
await deleteFileInfo(id);
|
await deleteFileInfo(id);
|
||||||
return;
|
return;
|
||||||
@@ -283,7 +282,7 @@ const fetchCategoryInfoFromServer = async (
|
|||||||
try {
|
try {
|
||||||
data = await trpc().category.get.query({ id });
|
data = await trpc().category.get.query({ id });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof TRPCClientError && e.data?.code === "NOT_FOUND") {
|
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||||
info.set(null);
|
info.set(null);
|
||||||
await deleteCategoryInfo(id as number);
|
await deleteCategoryInfo(id as number);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { TRPCClientError } from "@trpc/client";
|
|
||||||
import { encodeToBase64, decryptChallenge, signMessageRSA } from "$lib/modules/crypto";
|
import { encodeToBase64, decryptChallenge, signMessageRSA } from "$lib/modules/crypto";
|
||||||
import { trpc } from "$trpc/client";
|
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||||
|
|
||||||
export const requestSessionUpgrade = async (
|
export const requestSessionUpgrade = async (
|
||||||
encryptKeyBase64: string,
|
encryptKeyBase64: string,
|
||||||
@@ -16,7 +15,7 @@ export const requestSessionUpgrade = async (
|
|||||||
sigPubKey: verifyKeyBase64,
|
sigPubKey: verifyKeyBase64,
|
||||||
}));
|
}));
|
||||||
} catch (e) {
|
} 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, "Unregistered client"] as const;
|
||||||
}
|
}
|
||||||
return [false] as const;
|
return [false] as const;
|
||||||
@@ -31,7 +30,7 @@ export const requestSessionUpgrade = async (
|
|||||||
force,
|
force,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} 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, "Already logged in"] as const;
|
||||||
}
|
}
|
||||||
return [false] as const;
|
return [false] as const;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { TRPCClientError } from "@trpc/client";
|
|
||||||
import { storeMasterKeys } from "$lib/indexedDB";
|
import { storeMasterKeys } from "$lib/indexedDB";
|
||||||
import {
|
import {
|
||||||
encodeToBase64,
|
encodeToBase64,
|
||||||
@@ -11,7 +10,7 @@ import {
|
|||||||
} from "$lib/modules/crypto";
|
} from "$lib/modules/crypto";
|
||||||
import { requestSessionUpgrade } from "$lib/services/auth";
|
import { requestSessionUpgrade } from "$lib/services/auth";
|
||||||
import { masterKeyStore, type ClientKeys } from "$lib/stores";
|
import { masterKeyStore, type ClientKeys } from "$lib/stores";
|
||||||
import { trpc } from "$trpc/client";
|
import { trpc, isTRPCClientError } from "$trpc/client";
|
||||||
|
|
||||||
export const requestClientRegistration = async (
|
export const requestClientRegistration = async (
|
||||||
encryptKeyBase64: string,
|
encryptKeyBase64: string,
|
||||||
@@ -112,10 +111,7 @@ export const requestInitialMasterKeyAndHmacSecretRegistration = async (
|
|||||||
mekSig: await signMasterKeyWrapped(masterKeyWrapped, 1, signKey),
|
mekSig: await signMasterKeyWrapped(masterKeyWrapped, 1, signKey),
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (
|
if (isTRPCClientError(e) && (e.data?.code === "FORBIDDEN" || e.data?.code === "CONFLICT")) {
|
||||||
e instanceof TRPCClientError &&
|
|
||||||
(e.data?.code === "FORBIDDEN" || e.data?.code === "CONFLICT")
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// TODO: Error Handling
|
// TODO: Error Handling
|
||||||
|
|||||||
7
src/routes/(fullscreen)/gallery/+page.server.ts
Normal file
7
src/routes/(fullscreen)/gallery/+page.server.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { createCaller } from "$trpc/router.server";
|
||||||
|
import type { PageServerLoad } from "./$types";
|
||||||
|
|
||||||
|
export const load: PageServerLoad = async (event) => {
|
||||||
|
const files = await createCaller(event).file.list();
|
||||||
|
return { files };
|
||||||
|
};
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { trpc } from "$trpc/client";
|
|
||||||
import type { PageLoad } from "./$types";
|
|
||||||
|
|
||||||
export const load: PageLoad = async ({ fetch }) => {
|
|
||||||
const files = await trpc(fetch).file.list.query();
|
|
||||||
return { files };
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { createCaller } from "$trpc/router.server";
|
||||||
|
import type { PageServerLoad } from "./$types";
|
||||||
|
|
||||||
|
export const load: PageServerLoad = async (event) => {
|
||||||
|
const files = await createCaller(event).file.listWithoutThumbnail();
|
||||||
|
return { files };
|
||||||
|
};
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { trpc } from "$trpc/client";
|
|
||||||
import type { PageLoad } from "./$types";
|
|
||||||
|
|
||||||
export const load: PageLoad = async ({ fetch }) => {
|
|
||||||
const files = await trpc(fetch).file.listWithoutThumbnail.query();
|
|
||||||
return { files };
|
|
||||||
};
|
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
{#if files.length > 0}
|
{#if files.length > 0}
|
||||||
<RowVirtualizer
|
<RowVirtualizer
|
||||||
count={files.length}
|
count={files.length}
|
||||||
itemHeight={(index) => 48 + (index + 1 < files.length ? 4 : 0)}
|
itemHeight={(index) => 56 + (index + 1 < files.length ? 4 : 0)}
|
||||||
>
|
>
|
||||||
{#snippet item(index)}
|
{#snippet item(index)}
|
||||||
{@const file = files[index]!}
|
{@const file = files[index]!}
|
||||||
|
|||||||
@@ -21,14 +21,16 @@
|
|||||||
|
|
||||||
<div class="min-h-full space-y-4 bg-gray-100 px-4 pb-[5.5em] pt-4">
|
<div class="min-h-full space-y-4 bg-gray-100 px-4 pb-[5.5em] pt-4">
|
||||||
<p class="px-2 text-2xl font-bold text-gray-800">ArkVault</p>
|
<p class="px-2 text-2xl font-bold text-gray-800">ArkVault</p>
|
||||||
<div class="space-y-2 rounded-xl bg-white px-2 pb-4 pt-2">
|
<div class="rounded-xl bg-white p-2">
|
||||||
<EntryButton onclick={() => goto("/gallery")} class="w-full">
|
<EntryButton onclick={() => goto("/gallery")} class="w-full">
|
||||||
<p class="text-left font-semibold">사진 및 동영상</p>
|
<p class="text-left font-semibold">사진 및 동영상</p>
|
||||||
</EntryButton>
|
</EntryButton>
|
||||||
<div class="grid grid-cols-4 gap-2 px-2">
|
{#if mediaFiles.length > 0}
|
||||||
|
<div class="grid grid-cols-4 gap-2 p-2">
|
||||||
{#each mediaFiles as file}
|
{#each mediaFiles as file}
|
||||||
<FileThumbnailButton info={file} onclick={({ id }) => goto(`/file/${id}`)} />
|
<FileThumbnailButton info={file} onclick={({ id }) => goto(`/file/${id}`)} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
7
src/routes/(main)/menu/+page.server.ts
Normal file
7
src/routes/(main)/menu/+page.server.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { createCaller } from "$trpc/router.server";
|
||||||
|
import type { PageServerLoad } from "./$types";
|
||||||
|
|
||||||
|
export const load: PageServerLoad = async (event) => {
|
||||||
|
const { nickname } = await createCaller(event).user.get();
|
||||||
|
return { nickname };
|
||||||
|
};
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { trpc } from "$trpc/client";
|
|
||||||
import type { PageLoad } from "./$types";
|
|
||||||
|
|
||||||
export const load: PageLoad = async ({ fetch }) => {
|
|
||||||
const { nickname } = await trpc(fetch).user.get.query();
|
|
||||||
return { nickname };
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
import { createTRPCClient, httpBatchLink, TRPCClientError } from "@trpc/client";
|
||||||
import superjson from "superjson";
|
import superjson from "superjson";
|
||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
import type { AppRouter } from "./router.server";
|
import type { AppRouter } from "./router.server";
|
||||||
@@ -24,3 +24,7 @@ export const trpc = (fetch = globalThis.fetch) => {
|
|||||||
}
|
}
|
||||||
return client;
|
return client;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isTRPCClientError = (e: unknown): e is TRPCClientError<AppRouter> => {
|
||||||
|
return e instanceof TRPCClientError;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user