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.
This commit is contained in:
BoulderBadgeDad 2026-06-14 22:27:42 -07:00
parent 53391372c3
commit e2a8d3339a

View file

@ -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);
}
}