Skip to content

Commit

Permalink
fix: add notifications submenu actions
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Nov 25, 2024
1 parent 6659bf1 commit 6c78f26
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion src/components/LeftSidebar/ConversationsList/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@
</NcActionButton>

<NcActionSeparator />

<NcActionButton v-for="level in notificationLevels"
:key="level.value"
:model-value="notificationLevel.toString()"
:value="level.value.toString()"
type="radio"
@click="setNotificationLevel(level.value)">
<template #icon>
<component :is="notificationLevelIcon(level.value)" :size="16" />
</template>
{{ level.label }}
</NcActionButton>

<NcActionSeparator />

<NcActionButton type="checkbox"
:model-value="notifyCalls"
@click="setNotificationCalls(!notifyCalls)">
<template #icon>
<IconPhone :size="16" />
</template>
{{ t('spreed', 'Notify about calls') }}
</NcActionButton>
</template>
</template>

Expand Down Expand Up @@ -173,6 +196,7 @@
import { toRefs, ref } from 'vue'
import { isNavigationFailure, NavigationFailureType } from 'vue-router'

import IconAccount from 'vue-material-design-icons/Account.vue'
import IconArchive from 'vue-material-design-icons/Archive.vue'
import IconArchiveOff from 'vue-material-design-icons/ArchiveOff.vue'
import IconArrowLeft from 'vue-material-design-icons/ArrowLeft.vue'
Expand All @@ -184,13 +208,17 @@ import IconDelete from 'vue-material-design-icons/Delete.vue'
import IconExitToApp from 'vue-material-design-icons/ExitToApp.vue'
import IconEye from 'vue-material-design-icons/Eye.vue'
import IconEyeOff from 'vue-material-design-icons/EyeOff.vue'
import IconPhone from 'vue-material-design-icons/Phone.vue'
import IconStar from 'vue-material-design-icons/Star.vue'
import IconVolumeHigh from 'vue-material-design-icons/VolumeHigh.vue'
import IconVolumeOff from 'vue-material-design-icons/VolumeOff.vue'

import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { t } from '@nextcloud/l10n'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionCheckbox from '@nextcloud/vue/dist/Components/NcActionCheckbox.js'
import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
Expand All @@ -205,11 +233,18 @@ import { copyConversationLinkToClipboard } from '../../../utils/handleUrl.ts'

const supportsArchive = hasTalkFeature('local', 'archived-conversations-v2')

const notificationLevels = [
{ value: PARTICIPANT.NOTIFY.ALWAYS, label: t('spreed', 'All messages') },
{ value: PARTICIPANT.NOTIFY.MENTION, label: t('spreed', '@-mentions only') },
{ value: PARTICIPANT.NOTIFY.NEVER, label: t('spreed', 'Off') },
]

export default {
name: 'Conversation',

components: {
ConversationIcon,
IconAccount,
IconArchive,
IconArchiveOff,
IconArrowLeft,
Expand All @@ -221,8 +256,12 @@ export default {
IconExitToApp,
IconEye,
IconEyeOff,
IconPhone,
IconStar,
IconVolumeHigh,
IconVolumeOff,
NcActionButton,
NcActionCheckbox,
NcActionSeparator,
NcButton,
NcDialog,
Expand All @@ -247,7 +286,6 @@ export default {
type: 0,
displayName: '',
isFavorite: false,
notificationLevel: 0,
lastMessage: {},
canDeleteConversation: false,
canLeaveConversation: false,
Expand All @@ -265,13 +303,19 @@ export default {
const { item, isSearchResult } = toRefs(props)
const { counterType, conversationInformation } = useConversationInfo({ item, isSearchResult })

const notificationLevel = ref(item.value.notificationLevel)
const notifyCalls = ref(item.value.notificationCalls === PARTICIPANT.NOTIFY_CALLS.ON)

return {
supportsArchive,
submenu,
isLeaveDialogOpen,
isDeleteDialogOpen,
counterType,
conversationInformation,
notificationLevels,
notificationLevel,
notifyCalls,
}
},

Expand Down Expand Up @@ -385,6 +429,18 @@ export default {
this.$store.dispatch('toggleArchive', this.item)
},

notificationLevelIcon(value) {
switch (value) {
case PARTICIPANT.NOTIFY.ALWAYS:
return IconVolumeHigh
case PARTICIPANT.NOTIFY.MENTION:
return IconAccount
case PARTICIPANT.NOTIFY.NEVER:
default:
return IconVolumeOff
}
},

/**
* Set the notification level for the conversation
*
Expand All @@ -395,6 +451,20 @@ export default {
token: this.item.token,
notificationLevel: level,
})
this.notificationLevel = level
},

/**
* Set the call notification level for the conversation
*
* @param {boolean} value Whether or not call notifications are enabled
*/
async setNotificationCalls(value) {
await this.$store.dispatch('setNotificationCalls', {
token: this.item.token,
notificationCalls: value ? PARTICIPANT.NOTIFY_CALLS.ON : PARTICIPANT.NOTIFY_CALLS.OFF,
})
this.notifyCalls = value
},

onClick() {
Expand Down

0 comments on commit 6c78f26

Please sign in to comment.