fix(App): remove duplicated logic in beforeMount hook

- `tokenStore.updateToken` is called in App#beforeRouteChangeListener
- dispatch('joinConversation') is called in LeftSidebar#onRouteChange for users and EventBus for guests

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
This commit is contained in:
Maksim Sukharev
2025-06-27 11:26:15 +02:00
parent 44b88787e7
commit 1bd77fbb73

View File

@ -28,6 +28,7 @@ import { useIsMobile } from '@nextcloud/vue/composables/useIsMobile'
import { spawnDialog } from '@nextcloud/vue/functions/dialog'
import debounce from 'debounce'
import { provide } from 'vue'
import { START_LOCATION } from 'vue-router'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import NcContent from '@nextcloud/vue/components/NcContent'
import ConversationSettingsDialog from './components/ConversationSettings/ConversationSettingsDialog.vue'
@ -225,19 +226,17 @@ export default {
beforeMount() {
if (!getCurrentUser()) {
EventBus.once('conversations-received', (params) => {
if (params.singleConversation) {
this.$store.dispatch('joinConversation', { token: params.singleConversation.token })
}
})
EventBus.once('joined-conversation', () => {
this.fixmeDelayedSetupOfGuestUsers()
})
EventBus.on('should-refresh-conversations', this.debounceRefreshCurrentConversation)
}
if (this.$route.name === 'conversation') {
// Update current token in the token store
this.tokenStore.updateToken(this.$route.params.token)
// Automatically join the conversation as well
this.$store.dispatch('joinConversation', { token: this.$route.params.token })
}
window.addEventListener('unload', () => {
console.info('Navigating away, leaving conversation')
if (this.token) {
@ -343,6 +342,10 @@ export default {
})
EventBus.on('conversations-received', (params) => {
if (this.$route === START_LOCATION) {
// Initial navigation, should be handled in beforeRouteChangeListener
return
}
if (this.$route.name === 'conversation'
&& !this.$store.getters.conversation(this.token)) {
if (!params.singleConversation) {
@ -360,19 +363,6 @@ export default {
this.$router.push({ name: 'forbidden' })
})
/**
* Listens to the conversationsReceived globalevent, emitted by the conversationsList
* component each time a new batch of conversations is received and processed in
* the store.
*/
EventBus.once('conversations-received', () => {
if (!getCurrentUser()) {
// Set the current actor/participant for guests
const conversation = this.$store.getters.conversation(this.token)
this.actorStore.setCurrentParticipant(conversation)
}
})
const beforeRouteChangeListener = async (to, from, next) => {
if (this.isNextcloudTalkHashDirty) {
// Nextcloud Talk configuration changed, reload the page when changing configuration