Skip to content

Commit

Permalink
feat: Write Talk URL into location, not description
Browse files Browse the repository at this point in the history
Fall back to description if location is filled, e.g. for a hybrid event.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Aug 4, 2023
1 parent c394097 commit 7f39c7b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
37 changes: 24 additions & 13 deletions src/components/Editor/Invitees/InviteesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Check warning on line 76 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L76

Added line #L76 was not covered by tests
import FreeBusy from '../FreeBusy/FreeBusy.vue'
import {
showSuccess,
Expand Down Expand Up @@ -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)) {

Check warning on line 169 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L167-L169

Added lines #L167 - L169 were not covered by tests
return true
}
Expand Down Expand Up @@ -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.

Check warning on line 212 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L212

Added line #L212 was not covered by tests
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,

Check warning on line 223 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L220-L223

Added lines #L220 - L223 were not covered by tests
})
} else {
this.$store.commit('changeDescription', {
calendarObjectInstance: this.calendarObjectInstance,

Check warning on line 227 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L226-L227

Added lines #L226 - L227 were not covered by tests
description: this.calendarObjectInstance.description + NEW_LINE + NEW_LINE + url + NEW_LINE,
})
}
showSuccess(this.$t('calendar', 'Successfully appended link to talk room to description.'))

Check warning on line 231 in src/components/Editor/Invitees/InviteesList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Invitees/InviteesList.vue#L231

Added line #L231 was not covered by tests
}
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 {
Expand Down
10 changes: 5 additions & 5 deletions src/services/talkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check warning on line 131 in src/services/talkService.js

View check run for this annotation

Codecov / codecov/patch

src/services/talkService.js#L130-L131

Added lines #L130 - L131 were not covered by tests
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)

Check warning on line 138 in src/services/talkService.js

View check run for this annotation

Codecov / codecov/patch

src/services/talkService.js#L138

Added line #L138 was not covered by tests
}

/**
Expand Down

0 comments on commit 7f39c7b

Please sign in to comment.