From 845f9ad5c8e8157090a60a2accb08146ab0a322b Mon Sep 17 00:00:00 2001 From: tobinio Date: Sat, 9 Aug 2025 12:26:13 +0200 Subject: [PATCH] fix updating todos --- server/api/todos/.post.ts | 2 +- server/utils/db/todos.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/api/todos/.post.ts b/server/api/todos/.post.ts index c6f2962..3f91a0a 100644 --- a/server/api/todos/.post.ts +++ b/server/api/todos/.post.ts @@ -4,7 +4,7 @@ import { Todo } from "~~/shared/types"; export const Body = z.object({ data: Todo, - position: z.literal(["top", "bottom"]), + position: z.literal(["top", "bottom"]).optional(), previousId: z.uuid().optional(), }); diff --git a/server/utils/db/todos.ts b/server/utils/db/todos.ts index deb6538..63d4895 100644 --- a/server/utils/db/todos.ts +++ b/server/utils/db/todos.ts @@ -39,13 +39,13 @@ export const Todos = { async updateOrAdd( userId: string, todo: Todo, - position: "top" | "bottom", + position?: "top" | "bottom", previous?: UUID, ): Promise { const storage = useStorage(); const todos = await Todos.getAll(userId); - updateOrInsertAfterTodo(todos, todo, position, previous); + updateOrInsertAfterTodo(todos, todo, position ?? "top", previous); await storage.set(getKey(userId), todos); -- 2.51.2