mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 05:33:29 +01:00
16 lines
549 B
TypeScript
16 lines
549 B
TypeScript
import { useMutation } from '@tanstack/react-query';
|
|
import type { Settings } from '@yaakapp/api';
|
|
import { getSettings } from '../lib/store';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
|
|
export function useUpdateSettings() {
|
|
return useMutation<void, unknown, Partial<Settings>>({
|
|
mutationKey: ['update_settings'],
|
|
mutationFn: async (patch) => {
|
|
const settings = await getSettings();
|
|
const newSettings: Settings = { ...settings, ...patch };
|
|
await invokeCmd('cmd_update_settings', { settings: newSettings });
|
|
},
|
|
});
|
|
}
|