mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 21:53:36 +01:00
20 lines
475 B
TypeScript
20 lines
475 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import type { Settings } from '../lib/models';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
|
|
export function settingsQueryKey() {
|
|
return ['settings'];
|
|
}
|
|
|
|
export function useSettings() {
|
|
return (
|
|
useQuery({
|
|
queryKey: settingsQueryKey(),
|
|
queryFn: async () => {
|
|
const settings = (await invokeCmd('cmd_get_settings')) as Settings;
|
|
return [settings];
|
|
},
|
|
}).data?.[0] ?? undefined
|
|
);
|
|
}
|