Skip to content
Open
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
64 changes: 23 additions & 41 deletions src/components/Editor/AddTalkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,35 @@ export default {
},

/**
* Add the conversation as the event's conference.
* Add the conversation as the event's conference, and add its link to the
* location if it is empty or append it to the description otherwise.
*
* @param {string} url The conversation URL
*/
setConference(url) {
applyConversationLink(url) {
const eventComponent = this.calendarObjectInstance?.eventComponent
if (!eventComponent?.addConference) {
return
if (eventComponent?.addConference) {
// Replace an earlier conversation rather than stacking a second one
for (const conference of [...eventComponent.getConferenceList()]) {
eventComponent.deleteProperty(conference)
}

eventComponent.addConference(url, this.$t('calendar', 'Nextcloud Talk'), ['AUDIO', 'VIDEO', 'CHAT'])
}

// Replace an earlier conversation rather than stacking a second one
for (const conference of [...eventComponent.getConferenceList()]) {
eventComponent.deleteProperty(conference)
if ((this.calendarObjectInstance.location ?? '').trim() === '') {
this.$emit('updateLocation', url)
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to location.'))
return
}

eventComponent.addConference(url, this.$t('calendar', 'Nextcloud Talk'), ['AUDIO', 'VIDEO', 'CHAT'])
const NEW_LINE = '\r\n'
const description = this.calendarObjectInstance.description
? this.calendarObjectInstance.description + NEW_LINE + NEW_LINE + url
: url

this.$emit('updateDescription', description)
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to description.'))
},

async selectConversation(conversation) {
Expand All @@ -220,25 +233,7 @@ export default {
return
}

this.setConference(url)

if ((this.calendarObjectInstance.location ?? '').trim() === '') {
this.calendarObjectInstanceStore.changeLocation({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.calendarObjectInstanceStore was not defined in this component. This commit is actually a fix.

location: url,
})
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to location.'))
} else {
const NEW_LINE = '\r\n'
const updatedDescription = this.calendarObjectInstance.description
? this.calendarObjectInstance.description + NEW_LINE + NEW_LINE + url
: url

this.calendarObjectInstanceStore.changeDescription({
description: updatedDescription,
})
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to description.'))
}

this.applyConversationLink(url)
this.selectedConversation = conversation
} catch (error) {
logger.error('Error applying conversation to event:', { error })
Expand All @@ -249,7 +244,6 @@ export default {
},

async createTalkRoom(type) {
const NEW_LINE = '\r\n'
try {
this.creatingTalkRoom = true

Expand Down Expand Up @@ -279,19 +273,7 @@ export default {
throw new Error('Failed to generate URL from token')
}

this.setConference(url)

if ((this.calendarObjectInstance.location ?? '').trim() === '') {
this.$emit('updateLocation', url)
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to location.'))
} else {
const newDescription = this.calendarObjectInstance.description
? this.calendarObjectInstance.description + NEW_LINE + NEW_LINE + url + NEW_LINE
: url

this.$emit('updateDescription', newDescription)
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to description.'))
}
this.applyConversationLink(url)
this.closeModal()
} catch (error) {
logger.error('Error creating Talk room:', { error })
Expand Down
Loading