mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 20:00:29 +01:00
17 lines
487 B
TypeScript
17 lines
487 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { invoke } from '@tauri-apps/api';
|
|
import type { Workspace } from '../lib/models';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/ban-types
|
|
export function workspacesQueryKey(_?: {}) {
|
|
return ['workspaces'];
|
|
}
|
|
|
|
export function useWorkspaces() {
|
|
return (
|
|
useQuery(workspacesQueryKey(), async () => {
|
|
return (await invoke('list_workspaces')) as Workspace[];
|
|
}).data ?? []
|
|
);
|
|
}
|