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

Fix UI freeze when opening same path

This commit is contained in:
viown 2024-10-06 16:10:27 +03:00
parent 3a33ed9ffc
commit fb2d4487f3

View file

@ -39,6 +39,9 @@ class AppRouter {
constructor() {
document.addEventListener('viewshow', () => this.onViewShow());
this.lastPath = history.location.pathname + history.location.search;
this.listen();
// TODO: Can this baseRoute logic be simplified?
this.baseRoute = window.location.href.split('?')[0].replace(this.#getRequestFile(), '');
// support hashbang
@ -100,6 +103,20 @@ class AppRouter {
return this.promiseShow;
}
listen() {
history.listen(({ location }) => {
const normalizedPath = location.pathname.replace(/^!/, '');
const fullPath = normalizedPath + location.search;
if (fullPath === this.lastPath) {
console.debug('[appRouter] path did not change, resolving promise');
this.onViewShow();
}
this.lastPath = fullPath;
});
}
baseUrl() {
return this.baseRoute;
}