From 9051861f4d03c1197c61c44bac4426819cea1228 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 24 Nov 2019 15:54:24 +0200 Subject: [PATCH] Replace history entry if current route is null --- client/js/router.js | 9 ++++++++- client/js/vue.js | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/js/router.js b/client/js/router.js index 304d91b9..aaf7071b 100644 --- a/client/js/router.js +++ b/client/js/router.js @@ -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) { diff --git a/client/js/vue.js b/client/js/vue.js index be23984b..7f024ec7 100644 --- a/client/js/vue.js +++ b/client/js/vue.js @@ -71,9 +71,8 @@ store.watch( (sidebarOpen) => { if (window.outerWidth > constants.mobileViewportPixels) { storage.set("thelounge.state.sidebar", sidebarOpen); + vueApp.$emit("resize"); } - - vueApp.$emit("resize"); } );