From 7f39c7b7dc2690d3bd7532cceb1090d7f4e097b4 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 4 Aug 2023 15:13:53 +0200 Subject: [PATCH] feat: Write Talk URL into location, not description Fall back to description if location is filled, e.g. for a hybrid event. Signed-off-by: Christoph Wurst --- .../Editor/Invitees/InviteesList.vue | 37 ++++++++++++------- src/services/talkService.js | 10 ++--- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/components/Editor/Invitees/InviteesList.vue b/src/components/Editor/Invitees/InviteesList.vue index 03904479d2..24125de5f4 100644 --- a/src/components/Editor/Invitees/InviteesList.vue +++ b/src/components/Editor/Invitees/InviteesList.vue @@ -73,7 +73,7 @@ import InviteesListItem from './InviteesListItem.vue' import OrganizerListItem from './OrganizerListItem.vue' import NoAttendeesView from '../NoAttendeesView.vue' import OrganizerNoEmailError from '../OrganizerNoEmailError.vue' -import { createTalkRoom, doesDescriptionContainTalkLink } from '../../../services/talkService.js' +import { createTalkRoom, doesContainTalkLink } from '../../../services/talkService.js' import FreeBusy from '../FreeBusy/FreeBusy.vue' import { showSuccess, @@ -163,7 +163,10 @@ export default { return true } - if (doesDescriptionContainTalkLink(this.calendarObjectInstance.description)) { + if (doesContainTalkLink(this.calendarObjectInstance.location)) { + return true + } + if (doesContainTalkLink(this.calendarObjectInstance.description)) { return true } @@ -206,19 +209,27 @@ export default { this.calendarObjectInstance.description, ) - let newDescription - if (!this.calendarObjectInstance.description) { - newDescription = url + NEW_LINE + // Store in LOCATION property if it's missing/empty. Append to description otherwise. + if ((this.calendarObjectInstance.location ?? '').trim() === '') { + this.$store.commit('changeLocation', { + calendarObjectInstance: this.calendarObjectInstance, + location: url, + }) + showSuccess(this.$t('calendar', 'Successfully appended link to talk room to location.')) } else { - newDescription = this.calendarObjectInstance.description + NEW_LINE + NEW_LINE + url + NEW_LINE + if (!this.calendarObjectInstance.description) { + this.$store.commit('changeDescription', { + calendarObjectInstance: this.calendarObjectInstance, + description: url, + }) + } else { + this.$store.commit('changeDescription', { + calendarObjectInstance: this.calendarObjectInstance, + description: this.calendarObjectInstance.description + NEW_LINE + NEW_LINE + url + NEW_LINE, + }) + } + showSuccess(this.$t('calendar', 'Successfully appended link to talk room to description.')) } - - this.$store.commit('changeDescription', { - calendarObjectInstance: this.calendarObjectInstance, - description: newDescription, - }) - - showSuccess(this.$t('calendar', 'Successfully appended link to talk room to description.')) } catch (error) { showError(this.$t('calendar', 'Error creating Talk room')) } finally { diff --git a/src/services/talkService.js b/src/services/talkService.js index 9c9917da62..f2cfe79d67 100644 --- a/src/services/talkService.js +++ b/src/services/talkService.js @@ -122,20 +122,20 @@ export async function updateTalkParticipants(eventComponent) { } /** - * Checks whether the description already contains a talk link + * Checks whether the value contains a talk link * - * @param {?string} description Description of event + * @param {?string} text Haystack * @return {boolean} */ -export function doesDescriptionContainTalkLink(description) { - if (!description) { +export function doesContainTalkLink(text) { + if (!text) { return false } // TODO: there is most definitely a more reliable way, // but this works for now const fakeUrl = generateURLForToken() - return description.includes(fakeUrl) + return text.includes(fakeUrl) } /**