Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close modal after creating conversation #6658

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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 @@
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 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 @@
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
Loading