diff --git a/src/public/app/services/tasks.ts b/src/public/app/services/tasks.ts index 400e94712..becf7fd25 100644 --- a/src/public/app/services/tasks.ts +++ b/src/public/app/services/tasks.ts @@ -1,7 +1,13 @@ import server from "./server.js"; -export async function createNewTask(title: string) { +interface CreateNewTasksOpts { + parentNoteId: string; + title: string; +} + +export async function createNewTask({ parentNoteId, title }: CreateNewTasksOpts) { await server.post(`tasks`, { + parentNoteId, title }); } diff --git a/src/public/app/widgets/type_widgets/task_list.ts b/src/public/app/widgets/type_widgets/task_list.ts index b54ee35c7..a91d9879e 100644 --- a/src/public/app/widgets/type_widgets/task_list.ts +++ b/src/public/app/widgets/type_widgets/task_list.ts @@ -95,11 +95,14 @@ export default class TaskListWidget extends TypeWidget { } async #createNewTask(title: string) { - if (!title) { + if (!title || !this.noteId) { return; } - await taskService.createNewTask(title); + await taskService.createNewTask({ + title, + parentNoteId: this.noteId + }); } async doRefresh(note: FNote) {