Update icon beside the search box after the update dialog is dismissed
Shown as soon as an update is offered, so Later, a backdrop tap or a failed download all leave a one-tap way to update; it targets the newest build and disappears while updating. The search form and box now shrink so the icon never pushes Search off a phone screen.
This commit is contained in:
@@ -10519,6 +10519,7 @@ document.querySelectorAll('.chip').forEach((c) => {
|
||||
|
||||
// Mini now-playing bar
|
||||
$('miniPlayBtn').addEventListener('click', (e) => { e.stopPropagation(); Player.toggle(); });
|
||||
$('updateIconBtn').addEventListener('click', updateFromIcon);
|
||||
$('miniBar').addEventListener('click', () => {
|
||||
setHomeOverPlayer(false);
|
||||
hideMiniBar();
|
||||
@@ -11102,16 +11103,37 @@ async function hardReloadUI() {
|
||||
let _updateBannerShown = false;
|
||||
let _updating = false;
|
||||
let _updateToast = null;
|
||||
|
||||
// After "Later" (or a failed download) an update icon sits beside the search
|
||||
// box until the user takes the update; it always targets the newest build.
|
||||
function setUpdateIcon(on) {
|
||||
const b = $('updateIconBtn');
|
||||
if (b) b.classList.toggle('hidden', !on);
|
||||
}
|
||||
async function updateFromIcon() {
|
||||
if (_updating) return;
|
||||
setUpdateIcon(false);
|
||||
let target = null;
|
||||
try { target = await fetchServerBuild(); } catch { /* offline */ }
|
||||
if (!target || target === (RUNNING_BUILD || _knownBuildTag)) {
|
||||
if (!target) { toast('Offline — try the update again when connected'); setUpdateIcon(true); }
|
||||
return;
|
||||
}
|
||||
await applyUpdate(target);
|
||||
}
|
||||
|
||||
function showUpdateBanner(target) {
|
||||
// Only show the dialog once per page load
|
||||
if (_updateBannerShown) return;
|
||||
_updateBannerShown = true;
|
||||
// However the dialog is dismissed (Later, backdrop), the icon remains.
|
||||
setUpdateIcon(true);
|
||||
|
||||
// Show a modal dialog instead of a fleeting toast so the user can't miss it.
|
||||
const body = document.createElement('p');
|
||||
body.textContent = 'A new version of YT Player is available. Click "Refresh UI" to reload the page with the latest build. All your playlists and history are stored locally and will be preserved.';
|
||||
showModal('⬆ Update available', body, [
|
||||
{ label: 'Later', onClick: closeModal },
|
||||
{ label: 'Later', onClick: () => { closeModal(); setUpdateIcon(true); } },
|
||||
{ label: 'Refresh UI', primary: true, onClick: async () => {
|
||||
closeModal();
|
||||
await applyUpdate(target);
|
||||
@@ -11185,7 +11207,8 @@ async function applyUpdate(target, { quiet = false } = {}) {
|
||||
_updating = false;
|
||||
writeUpdateState(null);
|
||||
if (_updateToast) { _updateToast.remove(); _updateToast = null; }
|
||||
toast('⚠ Update didn’t download (' + (err && err.message ? err.message : 'connection problem') + '). It will be offered again.', { duration: 6000 });
|
||||
toast('⚠ Update didn’t download (' + (err && err.message ? err.message : 'connection problem') + '). Tap the update icon to try again.', { duration: 6000 });
|
||||
setUpdateIcon(true);
|
||||
// Let the next poll re-offer it.
|
||||
_updateBannerShown = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user