From e2a8d3339ae659ba7a56793fe96bf13a6dd7b320 Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Sun, 14 Jun 2026 22:27:42 -0700 Subject: [PATCH] video routing: re-assert the detail URL against late/async music redirects The reload restore could still be clobbered if music's router redirects on a later tick. Re-assert the /video-detail URL at 120/350/700ms after restore, but ONLY while the detail subpage is still showing, so it survives an async redirect without ever fighting genuine navigation away. --- webui/static/video/video-side.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/webui/static/video/video-side.js b/webui/static/video/video-side.js index 1ad6a6bf..d858a33c 100644 --- a/webui/static/video/video-side.js +++ b/webui/static/video/video-side.js @@ -277,12 +277,20 @@ // open-detail event), and so it lands AFTER music's initial routing — then // we re-assert the real URL it clobbered. if (bootDetail) { + var bootPath = buildDetailPath(bootDetail.source, bootDetail.kind, bootDetail.id); + var reassert = function () { + // Re-assert the URL only while we're still showing this detail (so a + // late async music redirect can't strand us on /dashboard) — never + // fights real navigation away. + if (DETAIL_PAGES[document.body.getAttribute('data-video-page')] && + window.location.pathname !== bootPath) { + try { history.replaceState({ videoDetail: bootDetail }, '', bootPath); } catch (e) { /* ignore */ } + } + }; setTimeout(function () { - var path = buildDetailPath(bootDetail.source, bootDetail.kind, bootDetail.id); - try { - history.replaceState({ videoDetail: bootDetail }, '', path); - } catch (e) { /* ignore */ } + reassert(); restoreDetail(bootDetail); + [120, 350, 700].forEach(function (ms) { setTimeout(reassert, ms); }); }, 0); } }