즐겨찾기 기능 구현

This commit is contained in:
static
2026-01-17 19:41:52 +09:00
parent befa535526
commit 420e30f677
24 changed files with 605 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ export interface SelectedEntry {
id: number;
dataKey: DataKey | undefined;
name: string;
isFavorite: boolean;
}
export const createContext = () => {
@@ -149,3 +150,25 @@ export const requestEntryDeletion = async (entry: SelectedEntry) => {
return false;
}
};
export const requestFavoriteToggle = async (entry: SelectedEntry) => {
try {
if (entry.type === "directory") {
if (entry.isFavorite) {
await trpc().favorites.removeDirectory.mutate({ id: entry.id });
} else {
await trpc().favorites.addDirectory.mutate({ id: entry.id });
}
} else {
if (entry.isFavorite) {
await trpc().favorites.removeFile.mutate({ id: entry.id });
} else {
await trpc().favorites.addFile.mutate({ id: entry.id });
}
}
return true;
} catch {
// TODO: Error Handling
return false;
}
};