diff --git a/frontend/js/ui.js b/frontend/js/ui.js index 5474ef6..f27c5a9 100644 --- a/frontend/js/ui.js +++ b/frontend/js/ui.js @@ -461,6 +461,13 @@ App.ui = App.ui || {}; if (reloadChannelBtn) { reloadChannelBtn.onclick = () => { + // Refresh means "give me the current everything": the videos + // below, and the app itself. The version check runs in the + // background and only acts if the deployed assets actually + // differ from what this tab is running. + if (App.version && typeof App.version.checkNow === 'function') { + App.version.checkNow(); + } App.videos.resetAndReload(); }; } diff --git a/frontend/js/version.js b/frontend/js/version.js index c121704..d2fda1a 100644 --- a/frontend/js/version.js +++ b/frontend/js/version.js @@ -114,6 +114,21 @@ App.version = App.version || {}; } } + // Same check the poller runs, on demand: the top-bar refresh button asks for + // it so a tab left open across a deploy picks the new build up right then, + // rather than up to POLL_INTERVAL_MS later. Changed CSS hot-swaps; changed + // JS/HTML reloads as soon as that won't interrupt playback. + App.version.checkNow = function() { + if (!baseline) { + // start() never got a manifest (endpoint down, or it hasn't run + // yet). Adopt whatever the server reports now so there's something + // to diff against next time -- there's no baseline to compare this + // one against, so nothing can be concluded from it today. + return fetchVersion().then((latest) => { baseline = latest; }).catch(() => {}); + } + return check(); + }; + App.version.start = async function() { try { baseline = await fetchVersion();