From 5b6d19b0262c837d0a75442aab76b5c387973445 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:59:04 -0800 Subject: [PATCH] update to latest zenstack + optimistic update --- .gitignore | 1 + components/Todo.tsx | 12 +- lib/hooks/__model_meta.ts | 482 +------------------------- lib/hooks/account.ts | 29 +- lib/hooks/list.ts | 29 +- lib/hooks/space-user.ts | 29 +- lib/hooks/space.ts | 29 +- lib/hooks/todo.ts | 29 +- lib/hooks/user.ts | 29 +- package-lock.json | 455 +++++++++++++++--------- package.json | 11 +- pages/_app.tsx | 4 +- pages/space/[slug]/[listId]/index.tsx | 63 ++-- tailwind.config.js | 2 +- 14 files changed, 508 insertions(+), 696 deletions(-) diff --git a/.gitignore b/.gitignore index 8a77877..a27fa53 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ logs node_modules/ .env.local .next +.zenstack_repl* diff --git a/components/Todo.tsx b/components/Todo.tsx index b7247a7..521f5bd 100644 --- a/components/Todo.tsx +++ b/components/Todo.tsx @@ -7,13 +7,14 @@ import TimeInfo from './TimeInfo'; type Props = { value: Todo & { owner: User }; + optimistic?: boolean; updated?: (value: Todo) => any; deleted?: (value: Todo) => any; }; -export default function TodoComponent({ value }: Props) { - const update = useUpdateTodo(); - const del = useDeleteTodo(); +export default function TodoComponent({ value, optimistic }: Props) { + const update = useUpdateTodo(undefined, true, true); // optimistic + const del = useDeleteTodo(undefined, true, true); // optimistic const deleteTodo = async () => { del.mutate({ where: { id: value.id } }); @@ -33,11 +34,12 @@ export default function TodoComponent({ value }: Props) {