Create new workspace, and more optimizations

This commit is contained in:
Gregory Schier
2023-03-18 19:36:31 -07:00
parent 5981588c95
commit d9b38efd97
20 changed files with 272 additions and 133 deletions

View File

@@ -3,9 +3,13 @@ import type { Workspace } from '../lib/models';
import { convertDates } from '../lib/models';
import { useQuery } from '@tanstack/react-query';
export function workspacesQueryKey() {
return ['workspaces'];
}
export function useWorkspaces() {
return (
useQuery(['workspaces'], async () => {
useQuery(workspacesQueryKey(), async () => {
const workspaces = (await invoke('workspaces')) as Workspace[];
return workspaces.map(convertDates);
}).data ?? []