diff --git a/src/App.vue b/src/App.vue index df1a5a1b7..442b79447 100644 --- a/src/App.vue +++ b/src/App.vue @@ -68,6 +68,7 @@ import ConversationSettingsDialog from './components/ConversationSettings/Conver import '@nextcloud/dialogs/styles/toast.scss' import { register } from 'extendable-media-recorder' import { connect } from 'extendable-media-recorder-wav-encoder' +import { CONVERSATION } from './constants' export default { name: 'App', @@ -176,6 +177,22 @@ export default { token() { return this.$store.getters.getToken() }, + + /** + * The current conversation + * @returns {object} The conversation object. + */ + currentConversation() { + return this.$store.getters.conversation(this.token) + }, + + /** + * Computes whether the current conversation is one to one + * @returns {boolean} The result + */ + isOneToOne() { + return this.currentConversation?.type === CONVERSATION.TYPE.ONE_TO_ONE + }, }, watch: { @@ -186,6 +203,15 @@ export default { this.setPageTitle(this.getConversationName(this.token), this.atLeastOneLastMessageIdChanged) }, + + token() { + // Collapse the sidebar if it's a 1to1 conversation + if (this.isOneToOne || BrowserStorage.getItem('sidebarOpen') === 'false') { + this.$store.dispatch('hideSidebar') + } else if (BrowserStorage.getItem('sidebarOpen') === 'true') { + this.$store.dispatch('showSidebar') + } + }, }, beforeDestroy() { @@ -317,6 +343,7 @@ export default { } else { beforeRouteChangeListener(to, from, next) } + }) if (getCurrentUser()) {