mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
IndexedDB에 즐겨찾기 여부를 항상 저장하도록 변경
This commit is contained in:
@@ -24,10 +24,10 @@
|
||||
<div class="h-full w-full bg-gray-100"></div>
|
||||
{/if}
|
||||
{#if info.isFavorite}
|
||||
<div class={["absolute bottom-0 right-0", !thumbnail && "rounded-full bg-white p-0.5"]}>
|
||||
<div class={["absolute bottom-0.5 right-0.5", !thumbnail && "rounded-full bg-white p-0.5"]}>
|
||||
<IconFavorite
|
||||
class="text-sm text-red-500"
|
||||
style="filter: drop-shadow(0 0 1px white) drop-shadow(0 0 1px white);"
|
||||
style="filter: drop-shadow(0 0 1px white) drop-shadow(0 0 1px white)"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div class={["absolute bottom-0 right-0", !thumbnail && "rounded-full bg-white p-0.5"]}>
|
||||
<IconFavorite
|
||||
class="text-xs text-red-500"
|
||||
style="filter: drop-shadow(0 0 1px white) drop-shadow(0 0 1px white);"
|
||||
style="filter: drop-shadow(0 0 1px white) drop-shadow(0 0 1px white)"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -4,7 +4,7 @@ interface DirectoryInfo {
|
||||
id: number;
|
||||
parentId: DirectoryId;
|
||||
name: string;
|
||||
isFavorite?: boolean;
|
||||
isFavorite: boolean;
|
||||
}
|
||||
|
||||
interface FileInfo {
|
||||
@@ -15,7 +15,7 @@ interface FileInfo {
|
||||
createdAt?: Date;
|
||||
lastModifiedAt: Date;
|
||||
categoryIds?: number[];
|
||||
isFavorite?: boolean;
|
||||
isFavorite: boolean;
|
||||
}
|
||||
|
||||
interface CategoryInfo {
|
||||
@@ -48,6 +48,23 @@ filesystem
|
||||
});
|
||||
});
|
||||
|
||||
filesystem.version(4).upgrade(async (trx) => {
|
||||
await Promise.all([
|
||||
trx
|
||||
.table("directory")
|
||||
.toCollection()
|
||||
.modify((directory) => {
|
||||
directory.isFavorite = false;
|
||||
}),
|
||||
trx
|
||||
.table("file")
|
||||
.toCollection()
|
||||
.modify((file) => {
|
||||
file.isFavorite = false;
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
export const getDirectoryInfos = async (parentId: DirectoryId) => {
|
||||
return await filesystem.directory.where({ parentId }).toArray();
|
||||
};
|
||||
|
||||
@@ -66,8 +66,8 @@ const cache = new FilesystemCache<CategoryId, MaybeCategoryInfo>({
|
||||
id: file.id,
|
||||
parentId: file.parent,
|
||||
contentType: file.contentType,
|
||||
isRecursive: file.isRecursive,
|
||||
isFavorite: file.isFavorite,
|
||||
isRecursive: file.isRecursive,
|
||||
...(await decryptFileMetadata(file, masterKey)),
|
||||
})),
|
||||
),
|
||||
|
||||
@@ -27,6 +27,7 @@ const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
|
||||
name: directory.name,
|
||||
subDirectories,
|
||||
files,
|
||||
isFavorite: directory.isFavorite,
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -62,6 +63,7 @@ const cache = new FilesystemCache<DirectoryId, MaybeDirectoryInfo>({
|
||||
parentId: directory.metadata!.parent,
|
||||
subDirectories,
|
||||
files,
|
||||
isFavorite: directory.metadata!.isFavorite,
|
||||
...metadata!,
|
||||
}
|
||||
: { id, subDirectories, files },
|
||||
|
||||
@@ -27,8 +27,8 @@ const cache = new FilesystemCache<number, MaybeFileInfo>({
|
||||
name: file.name,
|
||||
createdAt: file.createdAt,
|
||||
lastModifiedAt: file.lastModifiedAt,
|
||||
isFavorite: file.isFavorite,
|
||||
categories: categories?.filter((category) => !!category) ?? [],
|
||||
isFavorite: file.isFavorite,
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -56,8 +56,8 @@ const cache = new FilesystemCache<number, MaybeFileInfo>({
|
||||
name: metadata.name,
|
||||
createdAt: metadata.createdAt,
|
||||
lastModifiedAt: metadata.lastModifiedAt,
|
||||
isFavorite: file.isFavorite,
|
||||
categories,
|
||||
isFavorite: file.isFavorite,
|
||||
});
|
||||
} catch (e) {
|
||||
if (isTRPCClientError(e) && e.data?.code === "NOT_FOUND") {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
export type DataKey = { key: CryptoKey; version: Date };
|
||||
type AllUndefined<T> = { [K in keyof T]?: undefined };
|
||||
|
||||
export interface LocalDirectoryInfo {
|
||||
id: number;
|
||||
parentId: DirectoryId;
|
||||
dataKey?: DataKey;
|
||||
name: string;
|
||||
isFavorite?: boolean;
|
||||
subDirectories: SubDirectoryInfo[];
|
||||
files: SummarizedFileInfo[];
|
||||
isFavorite: boolean;
|
||||
}
|
||||
|
||||
export interface RootDirectoryInfo {
|
||||
@@ -18,6 +17,7 @@ export interface RootDirectoryInfo {
|
||||
name?: undefined;
|
||||
subDirectories: SubDirectoryInfo[];
|
||||
files: SummarizedFileInfo[];
|
||||
isFavorite?: undefined;
|
||||
}
|
||||
|
||||
export type DirectoryInfo = LocalDirectoryInfo | RootDirectoryInfo;
|
||||
@@ -37,7 +37,7 @@ export interface FileInfo {
|
||||
createdAt?: Date;
|
||||
lastModifiedAt: Date;
|
||||
categories: FileCategoryInfo[];
|
||||
isFavorite?: boolean;
|
||||
isFavorite: boolean;
|
||||
}
|
||||
|
||||
export type MaybeFileInfo =
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Kysely, sql } from "kysely";
|
||||
import { Kysely } from "kysely";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const up = async (db: Kysely<any>) => {
|
||||
|
||||
1
src/lib/types/utils.d.ts
vendored
Normal file
1
src/lib/types/utils.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
type AllUndefined<T> = { [K in keyof T]?: undefined };
|
||||
@@ -48,6 +48,7 @@ export const requestLegacyFiles = async (
|
||||
isLegacy: file.isLegacy,
|
||||
parentId: file.parent,
|
||||
contentType: file.contentType,
|
||||
isFavorite: file.isFavorite,
|
||||
...metadata,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -53,6 +53,7 @@ export const requestMissingThumbnailFiles = async (
|
||||
isLegacy: file.isLegacy,
|
||||
parentId: file.parent,
|
||||
contentType: file.contentType,
|
||||
isFavorite: file.isFavorite,
|
||||
...metadata,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -114,6 +114,7 @@ const fileRouter = router({
|
||||
createdAtIv: file.encCreatedAt?.iv,
|
||||
lastModifiedAt: file.encLastModifiedAt.ciphertext,
|
||||
lastModifiedAtIv: file.encLastModifiedAt.iv,
|
||||
isFavorite: file.isFavorite,
|
||||
}));
|
||||
}),
|
||||
|
||||
@@ -133,6 +134,7 @@ const fileRouter = router({
|
||||
createdAtIv: file.encCreatedAt?.iv,
|
||||
lastModifiedAt: file.encLastModifiedAt.ciphertext,
|
||||
lastModifiedAtIv: file.encLastModifiedAt.iv,
|
||||
isFavorite: file.isFavorite,
|
||||
}));
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user