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
26 changes: 15 additions & 11 deletions src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ import SearchBox from './SearchBox/SearchBox'
import debounce from 'debounce'
import { EventBus } from '../../services/EventBus'
import {
createGroupConversation,
createOneToOneConversation,
fetchConversations,
searchPossibleConversations,
Expand Down Expand Up @@ -342,25 +341,30 @@ export default {
},

/**
* Create a new conversation with the selected group/user/circle
* Create a new conversation with the selected user
* or bring up the dialog to create a new group/circle conversation
*
* @param {Object} item The autocomplete suggestion to start a conversation with
* @param {string} item.id The ID of the target
* @param {string} item.source The source of the target
* @param {string} item.label The displayname of the target
* @param {string} item.source The source of the target (e.g. users, groups, circle)
*/
async createAndJoinConversation(item) {
let response
if (item.source === 'users') {
// Create one-to-one conversation directly
response = await createOneToOneConversation(item.id)
const conversation = response.data.ocs.data
this.abortSearch()
EventBus.$once('joinedConversation', ({ token }) => {
this.$refs.conversationsList.scrollToConversation(token)
})
this.$store.dispatch('addConversation', conversation)
this.$router.push({ name: 'conversation', params: { token: conversation.token } }).catch(err => console.debug(`Error while pushing the new conversation's route: ${err}`))
} else {
response = await createGroupConversation(item.id, item.source)
// For other types we start the conversation creation dialog
EventBus.$emit('NewGroupConversationDialog', item)
}
const conversation = response.data.ocs.data
this.abortSearch()
EventBus.$once('joinedConversation', ({ token }) => {
this.$refs.conversationsList.scrollToConversation(token)
})
this.$store.dispatch('addConversation', conversation)
this.$router.push({ name: 'conversation', params: { token: conversation.token } }).catch(err => console.debug(`Error while pushing the new conversation's route: ${err}`))
},

async joinListedConversation(conversation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ import ListableSettings from '../../ConversationSettings/ListableSettings'
import isInCall from '../../../mixins/isInCall'
import participant from '../../../mixins/participant'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'
import { EventBus } from '../../../services/EventBus'

export default {

Expand Down Expand Up @@ -202,8 +203,21 @@ export default {
},
},

mounted() {
EventBus.$on('NewGroupConversationDialog', this.showModal)
},

destroyed() {
EventBus.$off('NewGroupConversationDialog', this.showModal)
},

methods: {
showModal() {
showModal(item) {
if (item) {
// Preload the conversation name from group selection
this.conversationNameInput = item.label
this.$store.dispatch('updateSelectedParticipants', item)
}
this.modal = true
},
/** Reinitialise the component to it's initial state. This is necessary
Expand Down