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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user