mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 19:31:12 +01:00
Clean up model fetching and loading states
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { useFastMutation } from './useFastMutation';
|
||||
import type { Folder } from '@yaakapp-internal/models';
|
||||
import {useSetAtom} from "jotai/index";
|
||||
import { getFolder } from '../lib/store';
|
||||
import { useSetAtom } from 'jotai/index';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import {foldersAtom} from "./useFolders";
|
||||
import {updateModelList} from "./useSyncModelStores";
|
||||
import { useFastMutation } from './useFastMutation';
|
||||
import { foldersAtom, getFolder } from './useFolders';
|
||||
import { updateModelList } from './useSyncModelStores';
|
||||
|
||||
export function useUpdateAnyFolder() {
|
||||
const setFolders = useSetAtom(foldersAtom);
|
||||
return useFastMutation<Folder, unknown, { id: string; update: (r: Folder) => Folder }>({
|
||||
mutationKey: ['update_any_folder'],
|
||||
mutationFn: async ({ id, update }) => {
|
||||
const folder = await getFolder(id);
|
||||
const folder = getFolder(id);
|
||||
if (folder === null) {
|
||||
throw new Error("Can't update a null folder");
|
||||
}
|
||||
@@ -20,6 +19,6 @@ export function useUpdateAnyFolder() {
|
||||
},
|
||||
onSuccess: async (folder) => {
|
||||
setFolders(updateModelList(folder));
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user