fix: use data.key instead of data.data in series_updated handler

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().
This commit is contained in:
2026-07-31 08:37:44 +02:00
parent d3cbb60c00
commit 163532b1ef
2 changed files with 11 additions and 5 deletions

View File

@@ -137,12 +137,15 @@ AniWorld.IndexSocketHandler = (function() {
socket.on(WS_EVENTS.SERIES_UPDATED, function(data) { socket.on(WS_EVENTS.SERIES_UPDATED, function(data) {
console.log('Series updated:', data); console.log('Series updated:', data);
// Use the data directly to update the series instead of full refresh // NOTE: websocket-client.js strips the outer {type, data, ...} wrapper
if (data && data.data && AniWorld.SeriesManager && AniWorld.SeriesManager.updateSingleSeries) { // before emitting, so `data` here is the inner series data object
AniWorld.SeriesManager.updateSingleSeries(data.data); // (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 { } else {
// Fallback to full reload if data is incomplete // 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) { if (AniWorld.SeriesManager && AniWorld.SeriesManager.loadSeries) {
AniWorld.SeriesManager.loadSeries(); AniWorld.SeriesManager.loadSeries();
} }

3
uv.lock generated Normal file
View File

@@ -0,0 +1,3 @@
version = 1
revision = 3
requires-python = ">=3.12"