Skip to content

Commit

Permalink
fix(settings): don't allow guests when breakout rooms are set
Browse files Browse the repository at this point in the history
- keep error handling in the store only
- disable option in dialog window

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed May 13, 2024
1 parent 72aac6e commit 2fe192d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
37 changes: 10 additions & 27 deletions src/components/ConversationSettings/LinkShareSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
</h4>

<template v-if="canModerate">
<p v-if="hasBreakoutRooms" class="app-settings-section__hint">
{{ t('spreed', 'Breakout rooms are not allowed in public conversations.') }}
</p>
<NcCheckboxRadioSwitch :checked="isSharedPublicly"
:disabled="isSaving"
:disabled="hasBreakoutRooms || isSaving"
type="switch"
aria-describedby="link_share_settings_hint"
@update:checked="toggleGuests">
Expand Down Expand Up @@ -133,18 +136,16 @@ export default {
return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation
},

hasBreakoutRooms() {
return this.conversation.breakoutRoomMode !== CONVERSATION.BREAKOUT_ROOM_MODE.NOT_CONFIGURED
},

isPasswordProtectionChecked() {
return this.conversation.hasPassword || this.showPasswordField
},
},

methods: {
focus() {
this.$nextTick(() => {
this.$refs.toggleGuests.focus()
})
},

async setConversationPassword(newPassword) {
this.isSaving = true
try {
Expand All @@ -169,27 +170,9 @@ export default {
},

async toggleGuests() {
const enabled = this.conversation.type !== CONVERSATION.TYPE.PUBLIC
const allowGuests = this.conversation.type !== CONVERSATION.TYPE.PUBLIC
this.isSaving = true
try {
await this.$store.dispatch('toggleGuests', {
token: this.token,
allowGuests: enabled,
})

if (enabled) {
showSuccess(t('spreed', 'You allowed guests'))
} else {
showSuccess(t('spreed', 'You disallowed guests'))
}
} catch (e) {
if (enabled) {
showError(t('spreed', 'Error occurred while allowing guests'))
} else {
showError(t('spreed', 'Error occurred while disallowing guests'))
}
console.error('Error toggling guest mode', e)
}
await this.$store.dispatch('toggleGuests', { token: this.token, allowGuests })
this.isSaving = false
},

Expand Down
7 changes: 6 additions & 1 deletion src/store/conversationsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,22 @@ const actions = {
}

try {
const conversation = Object.assign({}, getters.conversations[token])
const conversation = Object.assign({}, getters.conversation(token))
if (allowGuests) {
await makeConversationPublic(token)
conversation.type = CONVERSATION.TYPE.PUBLIC
showSuccess(t('spreed', 'You allowed guests'))
} else {
await makeConversationPrivate(token)
conversation.type = CONVERSATION.TYPE.GROUP
showSuccess(t('spreed', 'You disallowed guests'))
}
commit('addConversation', conversation)
} catch (error) {
console.error('Error while changing the conversation public status: ', error)
showError(allowGuests
? t('spreed', 'Error occurred while allowing guests')
: t('spreed', 'Error occurred while disallowing guests'))
}
},

Expand Down

0 comments on commit 2fe192d

Please sign in to comment.