mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-02 19:39:08 -05:00
21 lines
575 B
TypeScript
21 lines
575 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import type { Workspace } from '../lib/models';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/ban-types
|
|
export function workspacesQueryKey(_?: {}) {
|
|
return ['workspaces'];
|
|
}
|
|
|
|
export function useWorkspaces() {
|
|
return (
|
|
useQuery({
|
|
queryKey: workspacesQueryKey(),
|
|
queryFn: async () => {
|
|
const workspaces = await invokeCmd('cmd_list_workspaces');
|
|
return workspaces as Workspace[];
|
|
},
|
|
}).data ?? []
|
|
);
|
|
}
|