From 0ba4c9b9c78ee44889718e7b7d1b067961f3f757 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 23 Feb 2025 21:54:58 +0200 Subject: [PATCH] fix(tasks): content flash when updating list of tasks --- .../app/widgets/type_widgets/task_list.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/public/app/widgets/type_widgets/task_list.ts b/src/public/app/widgets/type_widgets/task_list.ts index b0e4ed9d2..8211c5921 100644 --- a/src/public/app/widgets/type_widgets/task_list.ts +++ b/src/public/app/widgets/type_widgets/task_list.ts @@ -57,11 +57,17 @@ const TPL = ` `; -function buildTask(task: FTask) { - return `\ -
  • - ${task.title} -
  • `; +function buildTasks(tasks: FTask[]) { + let html = ''; + + for (const task of tasks) { + html += `\ +
  • + ${task.title} +
  • `; + } + + return html; } export default class TaskListWidget extends TypeWidget { @@ -113,12 +119,9 @@ export default class TaskListWidget extends TypeWidget { return; } - this.$taskContainer.html(""); - const tasks = await froca.getTasks(this.noteId); - for (const task of tasks) { - this.$taskContainer.append($(buildTask(task))); - } + const tasksHtml = buildTasks(tasks); + this.$taskContainer.html(tasksHtml); } entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {