Replace history entry if current route is null

This commit is contained in:
Pavel Djundik 2019-11-24 15:54:24 +02:00
parent 049e9a1680
commit 9051861f4d
2 changed files with 9 additions and 3 deletions

View file

@ -127,7 +127,14 @@ function initialize() {
}
function navigate(routeName, params = {}) {
router.push({name: routeName, params}).catch(() => {});
if (router.currentRoute.name) {
router.push({name: routeName, params}).catch(() => {});
} else {
// If current route is null, replace the history entry
// This prevents invalid entries from lingering in history,
// and then the route guard preventing proper navigation
router.replace({name: routeName, params}).catch(() => {});
}
}
function switchToChannel(channel) {

View file

@ -71,9 +71,8 @@ store.watch(
(sidebarOpen) => {
if (window.outerWidth > constants.mobileViewportPixels) {
storage.set("thelounge.state.sidebar", sidebarOpen);
vueApp.$emit("resize");
}
vueApp.$emit("resize");
}
);