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,15 +171,18 @@ class TranscriptionApp {
} }
renderTasks() { renderTasks() {
const container = document.getElementById('tasksList'); if (this.renderTimeout) clearTimeout(this.renderTimeout);
const tasks = Array.from(this.tasks.values()); this.renderTimeout = setTimeout(() => {
const container = document.getElementById('tasksList');
const tasks = Array.from(this.tasks.values());
if (tasks.length === 0) { if (tasks.length === 0) {
container.innerHTML = '<p class="empty-state">Нет активных задач</p>'; container.innerHTML = '<p class="empty-state">Нет активных задач</p>';
return; return;
} }
container.innerHTML = tasks.map(task => this.renderTaskItem(task)).join(''); container.innerHTML = tasks.map(task => this.renderTaskItem(task)).join('');
}, 100);
} }
renderTaskItem(task) { renderTaskItem(task) {