Skip to content

Commit 342c850

Browse files
committed
✨ update series details after watching
1 parent f236b35 commit 342c850

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

js/display.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ export function closeDetails() {
178178
document.body.style.overflow = '';
179179
}
180180

181+
/**
182+
* Refreshes the details overlay for the active series.
183+
* This is useful after watching an episode to update the watched status.
184+
*/
185+
export function refreshActiveSeriesDetails() {
186+
if (activeDetailItem && (activeDetailItem.type === 'serie' || activeDetailItem.seasons !== undefined)) {
187+
openDetails(activeDetailItem);
188+
}
189+
}
190+
181191
/**
182192
* Plays the currently selected media in the details overlay.
183193
*/

js/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { fetchAllData } from './dataLoader.js';
99

1010
// Import display and rendering functions
11-
import { setupHero, renderHorizontalRow, renderGrid, renderNotifs, openDetails, closeDetails, playCurrentMedia, renderCollections, renderActorsList, closeActorDetails, renderActorsListSearch } from './display.js';
11+
import { setupHero, renderHorizontalRow, renderGrid, renderNotifs, openDetails, closeDetails, playCurrentMedia, renderCollections, renderActorsList, closeActorDetails, renderActorsListSearch, refreshActiveSeriesDetails } from './display.js';
1212

1313
// Import utility functions for video player and UI interactions
1414
import { closeVideo, toggleNotifs, toggleSettings, toggleMobileMenu, toggleMobileSearch, showLoader, hideLoader, hardenPlayerControls, initPlayerPersistence, downloadProgressBackup, openProgressImport, importProgressFromFile } from './utils.js';
@@ -30,6 +30,7 @@ window.toggleMobileMenu = toggleMobileMenu;
3030
window.downloadProgressBackup = downloadProgressBackup;
3131
window.openProgressImport = openProgressImport;
3232
window.closeActorDetails = closeActorDetails;
33+
window.refreshActiveSeriesDetails = refreshActiveSeriesDetails;
3334

3435
// Initialize application when DOM is fully loaded
3536
document.addEventListener('DOMContentLoaded', async () => {

js/utils.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,8 @@ function saveWatchProgress(player, isEnded = false) {
248248
markEpisodeWatched(title, season, epIndex, watched, timeToSave);
249249
}
250250

251-
// Clear current video state if marked as watched
252-
if (watched) {
253-
currentVideoSrc = '';
254-
currentVideoContext = null;
255-
}
251+
// Note: We keep currentVideoContext alive until closeVideo() is called
252+
// This allows us to refresh the series details page when closing
256253
}
257254

258255
/**
@@ -301,13 +298,27 @@ export function closeVideo() {
301298
saveWatchProgress(player);
302299
player.pause();
303300
player.src = "";
301+
302+
// Check if we were watching a series to refresh the details
303+
const wasWatchingSeries = currentVideoContext && currentVideoContext.type === 'series';
304+
304305
// Reset global state
305306
currentVideoSrc = '';
306307
currentVideoContext = null;
307308
overlay.classList.add('hidden');
308309

309310
// Clean up custom controls
310311
cleanupCustomVideoControls();
312+
313+
// Refresh series details if we were watching a series
314+
if (wasWatchingSeries) {
315+
// Use setTimeout to ensure the video overlay is fully closed before refreshing
316+
setTimeout(() => {
317+
if (window.refreshActiveSeriesDetails) {
318+
window.refreshActiveSeriesDetails();
319+
}
320+
}, 100);
321+
}
311322
}
312323

313324
/**
@@ -472,8 +483,7 @@ export function initPlayerPersistence() {
472483
// Mark as watched when video ends
473484
player.addEventListener('ended', () => {
474485
saveWatchProgress(player, true);
475-
currentVideoSrc = '';
476-
currentVideoContext = null;
486+
// Note: We keep context alive until closeVideo() to allow series details refresh
477487
});
478488
}
479489

0 commit comments

Comments
 (0)