Fix: add debounce to renderTasks to prevent frontend freeze during WebSocket updates

This commit is contained in:
keboss-m 2026-06-01 10:32:12 +03:00
parent 932dc71b8a
commit 2eee05a52f

View File

@ -7,6 +7,7 @@ class TranscriptionApp {
this.ws = null; this.ws = null;
this.tasks = new Map(); this.tasks = new Map();
this.currentFile = null; this.currentFile = null;
this.renderTimeout = null;
this.init(); this.init();
} }
@ -170,6 +171,8 @@ class TranscriptionApp {
} }
renderTasks() { renderTasks() {
if (this.renderTimeout) clearTimeout(this.renderTimeout);
this.renderTimeout = setTimeout(() => {
const container = document.getElementById('tasksList'); const container = document.getElementById('tasksList');
const tasks = Array.from(this.tasks.values()); const tasks = Array.from(this.tasks.values());
@ -179,6 +182,7 @@ class TranscriptionApp {
} }
container.innerHTML = tasks.map(task => this.renderTaskItem(task)).join(''); container.innerHTML = tasks.map(task => this.renderTaskItem(task)).join('');
}, 100);
} }
renderTaskItem(task) { renderTaskItem(task) {