Skip to content

Commit

Permalink
fix: close modal after creating conversation
Browse files Browse the repository at this point in the history
Signed-off-by: greta <[email protected]>
  • Loading branch information
GretaD committed Jan 24, 2025
1 parent 9353c15 commit 5c937cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 46 deletions.
12 changes: 7 additions & 5 deletions src/components/Editor/AddTalkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default {
calendarObjectInstance: this.calendarObjectInstance,
location: url,
})
showSuccess(this.$t('calendar', 'Successfully added Talk room link to location.'))
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to location.'))
} else {
const NEW_LINE = '\r\n'
const updatedDescription = this.calendarObjectInstance.description
Expand All @@ -156,7 +156,7 @@ export default {
calendarObjectInstance: this.calendarObjectInstance,
description: updatedDescription,
})
showSuccess(this.$t('calendar', 'Successfully added Talk room link to description.'))
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to description.'))
}

this.selectedConversation = conversation
Expand All @@ -183,18 +183,19 @@ export default {

if ((this.calendarObjectInstance.location ?? '').trim() === '') {
this.$emit('update-location', url)
showSuccess(this.$t('calendar', 'Successfully added Talk room link to location.'))
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('update-description', newDescription)
showSuccess(this.$t('calendar', 'Successfully added Talk room link to description.'))
showSuccess(this.$t('calendar', 'Successfully added Talk conversation link to description.'))
}
this.closeModal()
} catch (error) {
console.error('Error creating Talk room:', error)
showError(this.$t('calendar', 'Error creating Talk room.'))
showError(this.$t('calendar', 'Error creating Talk conversation'))
} finally {
this.creatingTalkRoom = false
}
Expand Down Expand Up @@ -238,6 +239,7 @@ export default {
padding: 16px;
text-align: right;
display: flex;
background-color: var(--color-main-background);
}
.talk_new-room {
margin-right: auto;
Expand Down
2 changes: 1 addition & 1 deletion src/services/talkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function createTalkRoom(eventTitle = null, eventDescription = null,
try {
const response = await HTTPClient.post(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room', {
roomType: 3,
roomName: eventTitle || t('calendar', 'Chat room for event'),
roomName: eventTitle || t('calendar', 'Talk conversation for event'),

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

View check run for this annotation

Codecov / codecov/patch

src/services/talkService.js#L27

Added line #L27 was not covered by tests
})

const conversation = response.data.ocs.data
Expand Down
42 changes: 2 additions & 40 deletions src/views/EditSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<AddTalkModal v-if="isModalOpen"
:conversations="talkConversations"
:calendar-object-instance="calendarObjectInstance"
@close="closeModal"
@close="isModalOpen = false"
@update-location="updateLocation"
@update-description="updateDescription" />
<IconVideo :size="20"
Expand Down Expand Up @@ -331,8 +331,7 @@ import useSettingsStore from '../store/settings.js'
import useCalendarObjectInstanceStore from '../store/calendarObjectInstance.js'
import { mapStores, mapState } from 'pinia'
import AddTalkModal from '../components/Editor/AddTalkModal.vue'
import { createTalkRoom, doesContainTalkLink } from '../services/talkService.js'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { doesContainTalkLink } from '../services/talkService.js'

Check failure on line 334 in src/views/EditSidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Multiple spaces found before 'doesContainTalkLink'
import IconVideo from 'vue-material-design-icons/Video.vue'

export default {
Expand Down Expand Up @@ -481,43 +480,6 @@ export default {
closeModal() {
this.isModalOpen = false
},

async createTalkRoom() {
const NEW_LINE = '\r\n'
try {
this.creatingTalkRoom = true
const url = await createTalkRoom(
this.calendarObjectInstance.title,
this.calendarObjectInstance.description,
)

// Store in LOCATION property if it's missing/empty. Append to description otherwise.
if ((this.calendarObjectInstance.location ?? '').trim() === '') {
this.calendarObjectInstanceStore.changeLocation({
calendarObjectInstance: this.calendarObjectInstance,
location: url,
})
showSuccess(this.$t('calendar', 'Successfully appended link to talk room to location.'))
} else {
if (!this.calendarObjectInstance.description) {
this.calendarObjectInstanceStore.changeDescription({
calendarObjectInstance: this.calendarObjectInstance,
description: url,
})
} else {
this.calendarObjectInstanceStore.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.'))
}
} catch (error) {
showError(this.$t('calendar', 'Error creating Talk room'))
} finally {
this.creatingTalkRoom = false
}
},
/**
* Update the start and end date of this event
*
Expand Down

0 comments on commit 5c937cb

Please sign in to comment.