diff --git a/src/App.vue b/src/App.vue index 235bc0e3c75..b2122d7df1c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -400,18 +400,22 @@ export default { return } } - // Update current token in the token store - this.tokenStore.updateToken(to.params.token) } + next() + } + + this.$router.afterEach((to, from) => { + /** + * Update current token in the token store + */ + this.tokenStore.updateToken(to.params.token ?? '') /** * Fires a global event that tells the whole app that the route has changed. The event * carries the from and to objects as payload */ EventBus.emit('route-change', { from, to }) - - next() - } + }) /** * Global before guard, this is called whenever a navigation is triggered. diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue index cd000caa5b9..b9c279e5a90 100644 --- a/src/components/LeftSidebar/LeftSidebar.vue +++ b/src/components/LeftSidebar/LeftSidebar.vue @@ -957,9 +957,6 @@ export default { } if (from.name === 'conversation') { this.$store.dispatch('leaveConversation', { token: from.params.token }) - if (to.name !== 'conversation') { - this.tokenStore.updateToken('') - } } if (to.name === 'conversation') { this.abortSearch() diff --git a/src/composables/useGetMessages.ts b/src/composables/useGetMessages.ts index 57a30fef984..ccf2918c8a5 100644 --- a/src/composables/useGetMessages.ts +++ b/src/composables/useGetMessages.ts @@ -223,7 +223,6 @@ export function useGetMessagesProvider() { } const focusMessageId = getMessageIdFromHash(to.hash) - const threadId = +(to.query.threadId ?? 0) if (from.hash !== to.hash && focusMessageId !== null) { // the hash changed, need to focus/highlight another message contextMessageId.value = focusMessageId @@ -235,7 +234,7 @@ export function useGetMessagesProvider() { contextMessageId.value = conversationLastMessageId.value } - await checkContextAndFocusMessage(to.params.token, contextMessageId.value, threadId) + await checkContextAndFocusMessage(to.params.token, contextMessageId.value, contextThreadId.value) } /**