Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions src/composables/useGetMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

/**
Expand Down