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:
parent
53391372c3
commit
e2a8d3339a
1 changed files with 12 additions and 4 deletions
|
|
@ -277,12 +277,20 @@
|
||||||
// open-detail event), and so it lands AFTER music's initial routing — then
|
// open-detail event), and so it lands AFTER music's initial routing — then
|
||||||
// we re-assert the real URL it clobbered.
|
// we re-assert the real URL it clobbered.
|
||||||
if (bootDetail) {
|
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 () {
|
setTimeout(function () {
|
||||||
var path = buildDetailPath(bootDetail.source, bootDetail.kind, bootDetail.id);
|
reassert();
|
||||||
try {
|
|
||||||
history.replaceState({ videoDetail: bootDetail }, '', path);
|
|
||||||
} catch (e) { /* ignore */ }
|
|
||||||
restoreDetail(bootDetail);
|
restoreDetail(bootDetail);
|
||||||
|
[120, 350, 700].forEach(function (ms) { setTimeout(reassert, ms); });
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue