mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-11-04 08:10:28 +09:00
파일 시스템 관련 상태와 변경 로직을 도메인 모듈로 통합하여 캐시가 자동으로 갱신되도록 개선하고 오류를 토스트로 표시하도록 변경
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ce73aa331
commit
4e82c5e556
67 files changed
+1091
-1082
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
getDirectoryInfo,
|
||||
getFileInfo,
|
||||
type FileInfo,
|
||||
type LocalCategoryInfo,
|
||||
type LocalDirectoryInfo,
|
||||
} from "#lib/features/filesystem/index.js";
|
||||
import { trpc } from "#trpc/client.js";
|
||||
|
||||
export interface SearchFilter {
|
||||
ancestorId: DirectoryId;
|
||||
inFavorites: boolean;
|
||||
categories: { info: LocalCategoryInfo; type: "include" | "exclude" }[];
|
||||
}
|
||||
|
||||
export interface SearchResult {
|
||||
directories: LocalDirectoryInfo[];
|
||||
files: FileInfo[];
|
||||
}
|
||||
|
||||
const getCategoryIds = (filter: SearchFilter, type: "include" | "exclude") => {
|
||||
return filter.categories.filter((category) => category.type === type).map(({ info }) => info.id);
|
||||
};
|
||||
|
||||
export const search = async (filter: SearchFilter) => {
|
||||
const { directories: directoriesRaw, files: filesRaw } = await trpc.search.search.query({
|
||||
ancestor: filter.ancestorId,
|
||||
inFavorites: filter.inFavorites,
|
||||
includeCategories: getCategoryIds(filter, "include"),
|
||||
excludeCategories: getCategoryIds(filter, "exclude"),
|
||||
});
|
||||
const [directories, files] = await Promise.all([
|
||||
Promise.all(
|
||||
directoriesRaw.map((directory) =>
|
||||
getDirectoryInfo(directory.id, { serverResponse: directory }),
|
||||
),
|
||||
),
|
||||
Promise.all(filesRaw.map((file) => getFileInfo(file.id, { serverResponse: file }))),
|
||||
]);
|
||||
return { directories, files } as SearchResult;
|
||||
};
|
||||
Reference in new issue
Block a user