mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 05:31:51 +02:00
A bunch of improvements to chaining
This commit is contained in:
@@ -1,19 +1,11 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { atom } from 'jotai/index';
|
||||
import type { Settings } from '../lib/models/Settings';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { getSettings } from '../lib/store';
|
||||
|
||||
export function settingsQueryKey() {
|
||||
return ['settings'];
|
||||
}
|
||||
const settings = await getSettings();
|
||||
export const settingsAtom = atom<Settings>(settings);
|
||||
|
||||
export function useSettings() {
|
||||
return (
|
||||
useQuery({
|
||||
queryKey: settingsQueryKey(),
|
||||
queryFn: async () => {
|
||||
const settings = (await invokeCmd('cmd_get_settings')) as Settings;
|
||||
return [settings];
|
||||
},
|
||||
}).data?.[0] ?? undefined
|
||||
);
|
||||
return useAtomValue(settingsAtom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user