Skip to content

Commit fb2d448

Browse files
committed
Fix UI freeze when opening same path
1 parent 3a33ed9 commit fb2d448

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/components/router/appRouter.js

+17
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class AppRouter {
3939
constructor() {
4040
document.addEventListener('viewshow', () => this.onViewShow());
4141

42+
this.lastPath = history.location.pathname + history.location.search;
43+
this.listen();
44+
4245
// TODO: Can this baseRoute logic be simplified?
4346
this.baseRoute = window.location.href.split('?')[0].replace(this.#getRequestFile(), '');
4447
// support hashbang
@@ -100,6 +103,20 @@ class AppRouter {
100103
return this.promiseShow;
101104
}
102105

106+
listen() {
107+
history.listen(({ location }) => {
108+
const normalizedPath = location.pathname.replace(/^!/, '');
109+
const fullPath = normalizedPath + location.search;
110+
111+
if (fullPath === this.lastPath) {
112+
console.debug('[appRouter] path did not change, resolving promise');
113+
this.onViewShow();
114+
}
115+
116+
this.lastPath = fullPath;
117+
});
118+
}
119+
103120
baseUrl() {
104121
return this.baseRoute;
105122
}

0 commit comments

Comments
 (0)