From 85b737c0aa507ece39d47e05ee32b6e43a87d9ff Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 6 Oct 2026 00:12:01 +0300 Subject: [PATCH] =?UTF-8?q?fix(lessons):=20=D0=B6=D0=B8=D0=B2=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BE=D1=82=D1=87?= =?UTF-8?q?=D1=91=D1=82=D0=BE=D0=B2=20=D0=BE=20=D0=B7=D0=B0=D0=BD=D1=8F?= =?UTF-8?q?=D1=82=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit broadcastLessonChanged() был объявлен, но нигде не вызывался — список отчётов не обновлялся после правки, создания, отката к версии/оригиналу и удаления. Публикация перенесена в invalidateLessonReports(), поэтому покрыты все 10 мест вызова, включая мутации через /api/v1/*. lessons.js подписан на lessons_changed с дебаунсом 300 мс; lesson_report_status продолжает слаться сразу для точечного обновления строки. --- public/js/lessons.js | 8 ++++++++ server.js | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/public/js/lessons.js b/public/js/lessons.js index 0733d54..d941d51 100644 --- a/public/js/lessons.js +++ b/public/js/lessons.js @@ -159,6 +159,7 @@ document.getElementById('searchInput').addEventListener('input', () => { }); let lessonLiveSource = null; +let lessonRefreshTimer = null; function connectLessonLive() { if (lessonLiveSource) { lessonLiveSource.close(); lessonLiveSource = null; } @@ -166,6 +167,13 @@ function connectLessonLive() { const t = sessionStorage.getItem('authToken'); if (!t) return; lessonLiveSource = new EventSource(`${API}/api/events?token=${encodeURIComponent(t)}`); + lessonLiveSource.addEventListener('lessons_changed', () => { + if (lessonRefreshTimer) return; + lessonRefreshTimer = setTimeout(() => { + lessonRefreshTimer = null; + loadLessons(); + }, 300); + }); lessonLiveSource.addEventListener('lesson_report_status', () => loadLessons()); lessonLiveSource.onerror = () => { if (lessonLiveSource) { lessonLiveSource.close(); lessonLiveSource = null; } diff --git a/server.js b/server.js index e0b74b4..6015f06 100644 --- a/server.js +++ b/server.js @@ -118,7 +118,10 @@ function invalidateSettings() { cacheDrop('setting:'); cacheDrop('share:payload: function invalidateStudents() { cacheDrop('students:'); } function invalidateGroups() { cacheDrop('groups:'); cacheDrop('students:'); cacheDrop('share:payload:'); } function invalidateEntries() { cacheDrop('entries:'); cacheDrop('students:'); cacheDrop('share:payload:'); } -function invalidateLessonReports() { cacheDrop('lessons:'); cacheDrop('stats:'); cacheDrop('dashboard:'); } +function invalidateLessonReports() { + cacheDrop('lessons:'); cacheDrop('stats:'); cacheDrop('dashboard:'); + broadcastLessonChanged(); +} function invalidateSessions() { cacheDrop('session:'); } function invalidateApiKeys() { cacheDrop('apikey:'); cacheDrop('rl:apikey'); }