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,13 +57,19 @@ const TPL = `
</div>
`;
function buildTask(task: FTask) {
return `\
function buildTasks(tasks: FTask[]) {
let html = '';
for (const task of tasks) {
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 {
private $taskContainer!: JQuery<HTMLElement>;
@ -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">) {