From 163532b1ef4df4618cf2501ebfc6ea8bb4d7cee5 Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 31 Jul 2026 08:37:44 +0200 Subject: [PATCH] fix: use data.key instead of data.data in series_updated handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The websocket-client strips the outer {type, data, ...} wrapper before emitting to handlers, so handlers receive the inner series data object directly (e.g. {key, name, missing_episodes}) — not {type, data: {...}}. The series_updated handler was checking data.data which always failed, causing every update to fall back to a full loadSeries() call instead of calling updateSingleSeries() directly. This prevented the missing episodes count from updating in real-time after a download completed. Fix: check data.key directly and pass data (not data.data) to updateSingleSeries(). --- src/server/web/static/js/index/socket-handler.js | 13 ++++++++----- uv.lock | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 uv.lock diff --git a/src/server/web/static/js/index/socket-handler.js b/src/server/web/static/js/index/socket-handler.js index 37859ad..96a294a 100644 --- a/src/server/web/static/js/index/socket-handler.js +++ b/src/server/web/static/js/index/socket-handler.js @@ -136,13 +136,16 @@ AniWorld.IndexSocketHandler = (function() { // Series events socket.on(WS_EVENTS.SERIES_UPDATED, function(data) { console.log('Series updated:', data); - - // Use the data directly to update the series instead of full refresh - if (data && data.data && AniWorld.SeriesManager && AniWorld.SeriesManager.updateSingleSeries) { - AniWorld.SeriesManager.updateSingleSeries(data.data); + + // NOTE: websocket-client.js strips the outer {type, data, ...} wrapper + // before emitting, so `data` here is the inner series data object + // (e.g. {key, name, missing_episodes, ...}) — NOT {type, data, ...}. + // AniWorld.SeriesManager.updateSingleSeries() expects this flat object. + if (data && data.key && AniWorld.SeriesManager && AniWorld.SeriesManager.updateSingleSeries) { + AniWorld.SeriesManager.updateSingleSeries(data); } else { // Fallback to full reload if data is incomplete - console.warn('Incomplete series update data, falling back to full reload'); + console.warn('Incomplete series update data, falling back to full reload', data); if (AniWorld.SeriesManager && AniWorld.SeriesManager.loadSeries) { AniWorld.SeriesManager.loadSeries(); } diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..7518fc9 --- /dev/null +++ b/uv.lock @@ -0,0 +1,3 @@ +version = 1 +revision = 3 +requires-python = ">=3.12"