diff options
-rw-r--r-- | src/components/ConversationSettings/ConversationSettingsDialog.vue | 2 | ||||
-rw-r--r-- | src/components/ConversationSettings/NotificationsSettings.vue | 38 | ||||
-rw-r--r-- | src/constants.js | 4 | ||||
-rw-r--r-- | src/services/conversationsService.js | 20 | ||||
-rw-r--r-- | src/store/conversationsStore.js | 11 |
5 files changed, 71 insertions, 4 deletions
diff --git a/src/components/ConversationSettings/ConversationSettingsDialog.vue b/src/components/ConversationSettings/ConversationSettingsDialog.vue index 550cd0841..32162eca8 100644 --- a/src/components/ConversationSettings/ConversationSettingsDialog.vue +++ b/src/components/ConversationSettings/ConversationSettingsDialog.vue @@ -42,7 +42,7 @@ <!-- Notifications settings --> <AppSettingsSection - :title="t('spreed', 'Chat notifications')"> + :title="t('spreed', 'Notifications')"> <NotificationsSettings :conversation="conversation" /> </AppSettingsSection> diff --git a/src/components/ConversationSettings/NotificationsSettings.vue b/src/components/ConversationSettings/NotificationsSettings.vue index f814d0a99..c00ff7a30 100644 --- a/src/components/ConversationSettings/NotificationsSettings.vue +++ b/src/components/ConversationSettings/NotificationsSettings.vue @@ -22,8 +22,10 @@ <template> <div> <div class="app-settings-section__hint"> - {{ t('spreed', 'Set the notification level for the current conversation. This will affect only the notifications you receive.') }} + {{ t('spreed', 'Set the notification settings for the current conversation.') }} </div> + + <h4>{{ t('spreed', 'Chat notifications') }}</h4> <a href="#" class="radio-element" @@ -85,11 +87,20 @@ title="" :size="20" /> </a> + + <h4>{{ t('spreed', 'Call notifications') }}</h4> + <CheckboxRadioSwitch + id="notification_calls" + :checked.sync="notifyCalls" + @update:checked="setNotificationCalls"> + {{ t('spreed', 'Notify about calls in this conversation') }} + </CheckboxRadioSwitch> </div> </template> <script> import { PARTICIPANT } from '../../constants' +import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch' import VolumeHigh from 'vue-material-design-icons/VolumeHigh' import Account from 'vue-material-design-icons/Account' import VolumeOff from 'vue-material-design-icons/VolumeOff' @@ -99,6 +110,7 @@ export default { name: 'NotificationsSettings', components: { + CheckboxRadioSwitch, VolumeHigh, Account, VolumeOff, @@ -112,6 +124,12 @@ export default { }, }, + data() { + return { + notifyCalls: true, + } + }, + computed: { token() { return this.conversation.token @@ -130,6 +148,10 @@ export default { }, }, + mounted() { + this.notifyCalls = this.conversation.notificationCalls === PARTICIPANT.NOTIFY_CALLS.ON + }, + methods: { /** * Set the notification level for the conversation @@ -139,6 +161,16 @@ export default { async setNotificationLevel(notificationLevel) { await this.$store.dispatch('setNotificationLevel', { token: this.token, notificationLevel }) }, + + /** + * Set the call notification level for the conversation + * + * @param {boolean} isChecked Whether or not call notifications are enabled + */ + async setNotificationCalls(isChecked) { + const notificationCalls = isChecked ? PARTICIPANT.NOTIFY_CALLS.ON : PARTICIPANT.NOTIFY_CALLS.OFF + await this.$store.dispatch('setNotificationCalls', { token: this.token, notificationCalls }) + }, }, } </script> @@ -166,6 +198,10 @@ export default { } } +h4 { + font-weight: bold; +} + .check { display: flex; margin: 0 8px 0 auto; diff --git a/src/constants.js b/src/constants.js index be0428881..dc4cd9387 100644 --- a/src/constants.js +++ b/src/constants.js @@ -79,6 +79,10 @@ export const PARTICIPANT = { MENTION: 2, NEVER: 3, }, + NOTIFY_CALLS: { + OFF: 0, + ON: 1, + }, TYPE: { OWNER: 1, MODERATOR: 2, diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js index fffbb9005..7138b0fa9 100644 --- a/src/services/conversationsService.js +++ b/src/services/conversationsService.js @@ -229,9 +229,9 @@ const removeFromFavorites = async function(token) { } /** - * Remove a conversation from the favorites + * Set notification level * - * @param {string} token The token of the conversation to be removed from favorites + * @param {string} token The token of the conversation to change the notification level * @param {number} level The notification level to set. */ const setNotificationLevel = async function(token, level) { @@ -244,6 +244,21 @@ const setNotificationLevel = async function(token, level) { } /** + * Set call notifications + * + * @param {string} token The token of the conversation to change the call notification level + * @param {number} level The call notification level. + */ +const setNotificationCalls = async function(token, level) { + try { + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/notify-calls', { token }), { level }) + return response + } catch (error) { + console.debug('Error while setting the call notification level: ', error) + } +} + +/** * Make the conversation public * * @param {string} token The token of the conversation to be removed from favorites @@ -352,6 +367,7 @@ export { addToFavorites, removeFromFavorites, setNotificationLevel, + setNotificationCalls, makePublic, makePrivate, setSIPEnabled, diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index 31a3caf3b..81e209c1f 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -37,6 +37,7 @@ import { deleteConversation, clearConversationHistory, setNotificationLevel, + setNotificationCalls, } from '../services/conversationsService' import { getCurrentUser } from '@nextcloud/auth' import { CONVERSATION, WEBINAR, PARTICIPANT } from '../constants' @@ -136,6 +137,10 @@ const mutations = { setNotificationLevel(state, { token, notificationLevel }) { Vue.set(state.conversations[token], 'notificationLevel', notificationLevel) }, + + setNotificationCalls(state, { token, notificationCalls }) { + Vue.set(state.conversations[token], 'notificationCalls', notificationCalls) + }, } const actions = { @@ -440,6 +445,12 @@ const actions = { commit('setNotificationLevel', { token, notificationLevel }) }, + async setNotificationCalls({ commit }, { token, notificationCalls }) { + await setNotificationCalls(token, notificationCalls) + + commit('setNotificationCalls', { token, notificationCalls }) + }, + /** * Creates a new one to one conversation in the backend * with the given actor then adds it to the store. |