1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #3461 from dmitrylyzo/fix-popstate

Fix page reload on return
This commit is contained in:
Bill Thornton 2022-02-25 15:20:37 -05:00 committed by GitHub
commit a79073480b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,16 +34,21 @@ class AppRouter {
constructor() { constructor() {
// WebKit fires a popstate event on document load // WebKit fires a popstate event on document load
// Skip it using timeout // Skip it using boolean
// For Tizen 2.x // For Tizen 2.x
// https://stackoverflow.com/a/12214354 // See `page` node module
let loaded = document.readyState === 'complete';
if (!loaded) {
window.addEventListener('load', () => { window.addEventListener('load', () => {
setTimeout(() => { setTimeout(() => {
window.addEventListener('popstate', () => { loaded = true;
this.popstateOccurred = true;
});
}, 0); }, 0);
}); });
}
window.addEventListener('popstate', () => {
if (!loaded) return;
this.popstateOccurred = true;
});
document.addEventListener('viewshow', () => this.onViewShow()); document.addEventListener('viewshow', () => this.onViewShow());