Fix: add debounce to renderTasks to prevent frontend freeze during WebSocket updates
This commit is contained in:
parent
932dc71b8a
commit
2eee05a52f
@ -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) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user