mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
검색 필터에 즐겨찾기 여부 추가
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
includeImages: boolean;
|
||||
includeVideos: boolean;
|
||||
includeDirectories: boolean;
|
||||
searchInFavorites: boolean;
|
||||
searchInDirectory: boolean;
|
||||
categories: SearchFilter["categories"];
|
||||
}
|
||||
@@ -36,6 +37,7 @@
|
||||
includeImages: false,
|
||||
includeVideos: false,
|
||||
includeDirectories: false,
|
||||
searchInFavorites: false,
|
||||
searchInDirectory: false,
|
||||
categories: [],
|
||||
});
|
||||
@@ -45,6 +47,7 @@
|
||||
filters.includeImages ||
|
||||
filters.includeVideos ||
|
||||
filters.includeDirectories ||
|
||||
filters.searchInFavorites ||
|
||||
filters.name.trim().length > 0,
|
||||
);
|
||||
|
||||
@@ -81,7 +84,9 @@
|
||||
|
||||
return sortEntries(
|
||||
[...directories, ...files].filter(
|
||||
({ name }) => !nameFilter || searchString(name, nameFilter),
|
||||
(entry) =>
|
||||
(!nameFilter || searchString(entry.name, nameFilter)) &&
|
||||
(!filters.searchInFavorites || entry.isFavorite),
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -118,7 +123,7 @@
|
||||
},
|
||||
};
|
||||
|
||||
$effect(() => {
|
||||
$effect.pre(() => {
|
||||
if (data.directoryId) {
|
||||
HybridPromise.resolve(getDirectoryInfo(data.directoryId, $masterKeyStore?.get(1)?.key!)).then(
|
||||
(res) => {
|
||||
@@ -132,6 +137,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
$effect.pre(() => {
|
||||
filters.searchInFavorites = data.fromFavorites;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
// Svelte sucks
|
||||
hasAnyFilter;
|
||||
@@ -172,6 +181,7 @@
|
||||
{#if !hasCategoryFilter}
|
||||
<Chip bind:selected={filters.includeDirectories}>폴더</Chip>
|
||||
{/if}
|
||||
<Chip bind:selected={filters.searchInFavorites}>즐겨찾기</Chip>
|
||||
{#if directoryInfo?.exists}
|
||||
<Chip bind:selected={filters.searchInDirectory}>
|
||||
위치: {directoryInfo.name}
|
||||
|
||||
@@ -4,15 +4,18 @@ import type { PageLoad } from "./$types";
|
||||
|
||||
export const load: PageLoad = ({ url }) => {
|
||||
const directoryId = url.searchParams.get("directoryId");
|
||||
const from = url.searchParams.get("from");
|
||||
|
||||
const zodRes = z
|
||||
.object({
|
||||
directoryId: z.coerce.number().int().positive().nullable(),
|
||||
from: z.enum(["favorites"]).nullable(),
|
||||
})
|
||||
.safeParse({ directoryId });
|
||||
.safeParse({ directoryId, from });
|
||||
if (!zodRes.success) error(400, "Invalid query parameters");
|
||||
|
||||
return {
|
||||
directoryId: zodRes.data.directoryId,
|
||||
fromFavorites: zodRes.data.from === "favorites",
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user