Skip to content

Commit

Permalink
Merge pull request #6168 from viown/fix-ui-freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill authored Oct 9, 2024
2 parents 4c24d6d + fb2d448 commit 38d095b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/router/appRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 38d095b

Please sign in to comment.