fix(tasks): content flash when updating list of tasks

This commit is contained in:
Elian Doran 2025-02-23 21:54:58 +02:00
parent 31fcf7ea60
commit 0ba4c9b9c7
No known key found for this signature in database

View File

@ -57,11 +57,17 @@ const TPL = `
</div> </div>
`; `;
function buildTask(task: FTask) { function buildTasks(tasks: FTask[]) {
return `\ let html = '';
<li class="task">
<input type="checkbox" class="check" data-task-id="${task.taskId}" ${task.isDone ? "checked" : ""} /> ${task.title} for (const task of tasks) {
</li>`; html += `\
<li class="task">
<input type="checkbox" class="check" data-task-id="${task.taskId}" ${task.isDone ? "checked" : ""} /> ${task.title}
</li>`;
}
return html;
} }
export default class TaskListWidget extends TypeWidget { export default class TaskListWidget extends TypeWidget {
@ -113,12 +119,9 @@ export default class TaskListWidget extends TypeWidget {
return; return;
} }
this.$taskContainer.html("");
const tasks = await froca.getTasks(this.noteId); const tasks = await froca.getTasks(this.noteId);
for (const task of tasks) { const tasksHtml = buildTasks(tasks);
this.$taskContainer.append($(buildTask(task))); this.$taskContainer.html(tasksHtml);
}
} }
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {