Skip to content

Commit 244cfa3

Browse files
committed
feat: add UI elements for important/sensitive conversations
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent 2f4d040 commit 244cfa3

3 files changed

Lines changed: 140 additions & 0 deletions

File tree

src/components/ConversationSettings/NotificationsSettings.vue

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,32 @@
2929
@update:model-value="setNotificationCalls">
3030
{{ t('spreed', 'Notify about calls in this conversation') }}
3131
</NcCheckboxRadioSwitch>
32+
33+
<NcCheckboxRadioSwitch v-if="supportImportantConversations"
34+
id="important"
35+
v-model="isImportant"
36+
aria-describedby="important-hint"
37+
type="switch"
38+
@update:model-value="toggleImportant">
39+
{{ t('spreed', 'Important conversation') }}
40+
</NcCheckboxRadioSwitch>
41+
42+
<p id="important-hint" class="notifications__hint">
43+
{{ t('spreed', '"Do not disturb" user status is ignored for important conversations') }}
44+
</p>
45+
46+
<NcCheckboxRadioSwitch v-if="supportSensitiveConversations"
47+
id="sensitive"
48+
v-model="isSensitive"
49+
aria-describedby="sensitive-hint"
50+
type="switch"
51+
@update:model-value="toggleSensitive">
52+
{{ t('spreed', 'Sensitive conversation') }}
53+
</NcCheckboxRadioSwitch>
54+
55+
<p id="sensitive-hint" class="notifications__hint">
56+
{{ t('spreed', 'Message preview will be disabled in conversation list and notifications') }}
57+
</p>
3258
</div>
3359
</template>
3460

@@ -44,6 +70,9 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwit
4470
import { PARTICIPANT } from '../../constants.ts'
4571
import { hasTalkFeature } from '../../services/CapabilitiesManager.ts'
4672
73+
const supportImportantConversations = hasTalkFeature('local', 'important-conversations')
74+
const supportSensitiveConversations = hasTalkFeature('local', 'sensitive-conversations')
75+
4776
const notificationLevels = [
4877
{ value: PARTICIPANT.NOTIFY.ALWAYS, label: t('spreed', 'All messages') },
4978
{ value: PARTICIPANT.NOTIFY.MENTION, label: t('spreed', '@-mentions only') },
@@ -67,13 +96,17 @@ export default {
6796
setup() {
6897
return {
6998
notificationLevels,
99+
supportImportantConversations,
100+
supportSensitiveConversations,
70101
}
71102
},
72103
73104
data() {
74105
return {
75106
notifyCalls: this.conversation.notificationCalls === PARTICIPANT.NOTIFY_CALLS.ON,
76107
notificationLevel: this.conversation.notificationLevel.toString(),
108+
isImportant: this.conversation.isImportant,
109+
isSensitive: this.conversation.isSensitive,
77110
}
78111
},
79112
@@ -115,6 +148,24 @@ export default {
115148
const notificationCalls = isChecked ? PARTICIPANT.NOTIFY_CALLS.ON : PARTICIPANT.NOTIFY_CALLS.OFF
116149
await this.$store.dispatch('setNotificationCalls', { token: this.conversation.token, notificationCalls })
117150
},
151+
152+
/**
153+
* Toggle the important flag for the conversation
154+
*
155+
* @param {boolean} isImportant The important flag to set.
156+
*/
157+
async toggleImportant(isImportant) {
158+
await this.$store.dispatch('toggleImportant', { token: this.conversation.token, isImportant })
159+
},
160+
161+
/**
162+
* Toggle the sensitive flag for the conversation
163+
*
164+
* @param {boolean} isSensitive The sensitive flag to set.
165+
*/
166+
async toggleSensitive(isSensitive) {
167+
await this.$store.dispatch('toggleSensitive', { token: this.conversation.token, isSensitive })
168+
}
118169
},
119170
}
120171
</script>
@@ -125,4 +176,8 @@ export default {
125176
align-items: center;
126177
gap: calc(2 * var(--default-grid-baseline));
127178
}
179+
180+
.notifications__hint {
181+
color: var(--color-text-maxcontrast);
182+
}
128183
</style>

src/components/LeftSidebar/ConversationsList/Conversation.vue

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,30 @@
163163
{{ t('spreed', 'Notify about calls') }}
164164
</NcActionButton>
165165
</template>
166+
167+
<template v-if="supportImportantConversations || supportSensitiveConversations">
168+
<NcActionSeparator />
169+
170+
<NcActionButton v-if="supportImportantConversations"
171+
type="checkbox"
172+
:model-value="item.isImportant"
173+
@click="toggleImportant(!item.isImportant)">
174+
<template #icon>
175+
<IconMessageAlert :size="16" />
176+
</template>
177+
{{ t('spreed', 'Important conversation') }}
178+
</NcActionButton>
179+
180+
<NcActionButton v-if="supportSensitiveConversations"
181+
type="checkbox"
182+
:model-value="item.isSensitive"
183+
@click="toggleSensitive(!item.isSensitive)">
184+
<template #icon>
185+
<IconShieldLock :size="16" />
186+
</template>
187+
{{ t('spreed', 'Sensitive conversation') }}
188+
</NcActionButton>
189+
</template>
166190
</template>
167191
</template>
168192

@@ -239,7 +263,9 @@ import IconDelete from 'vue-material-design-icons/Delete.vue'
239263
import IconExitToApp from 'vue-material-design-icons/ExitToApp.vue'
240264
import IconEye from 'vue-material-design-icons/Eye.vue'
241265
import IconEyeOff from 'vue-material-design-icons/EyeOff.vue'
266+
import IconMessageAlert from 'vue-material-design-icons/MessageAlert.vue'
242267
import IconPhoneRing from 'vue-material-design-icons/PhoneRing.vue'
268+
import IconShieldLock from 'vue-material-design-icons/ShieldLock.vue'
243269
import IconStar from 'vue-material-design-icons/Star.vue'
244270
import IconVideo from 'vue-material-design-icons/Video.vue'
245271
import IconVolumeHigh from 'vue-material-design-icons/VolumeHigh.vue'
@@ -263,6 +289,8 @@ import { hasTalkFeature } from '../../../services/CapabilitiesManager.ts'
263289
import { copyConversationLinkToClipboard } from '../../../utils/handleUrl.ts'
264290
265291
const supportsArchive = hasTalkFeature('local', 'archived-conversations-v2')
292+
const supportImportantConversations = hasTalkFeature('local', 'important-conversations')
293+
const supportSensitiveConversations = hasTalkFeature('local', 'sensitive-conversations')
266294
267295
const notificationLevels = [
268296
{ value: PARTICIPANT.NOTIFY.ALWAYS, label: t('spreed', 'All messages') },
@@ -287,7 +315,9 @@ export default {
287315
IconExitToApp,
288316
IconEye,
289317
IconEyeOff,
318+
IconMessageAlert,
290319
IconPhoneRing,
320+
IconShieldLock,
291321
IconStar,
292322
IconVolumeHigh,
293323
IconVolumeOff,
@@ -322,6 +352,7 @@ export default {
322352
canDeleteConversation: false,
323353
canLeaveConversation: false,
324354
hasCall: false,
355+
isImportant: false,
325356
isSensitive: false,
326357
}
327358
},
@@ -345,6 +376,8 @@ export default {
345376
return {
346377
AVATAR,
347378
supportsArchive,
379+
supportImportantConversations,
380+
supportSensitiveConversations,
348381
submenu,
349382
isLeaveDialogOpen,
350383
isDeleteDialogOpen,
@@ -529,6 +562,24 @@ export default {
529562
})
530563
},
531564
565+
/**
566+
* Toggle the important flag for the conversation
567+
*
568+
* @param {boolean} isImportant The important flag to set.
569+
*/
570+
async toggleImportant(isImportant) {
571+
await this.$store.dispatch('toggleImportant', { token: this.item.token, isImportant })
572+
},
573+
574+
/**
575+
* Toggle the sensitive flag for the conversation
576+
*
577+
* @param {boolean} isSensitive The sensitive flag to set.
578+
*/
579+
async toggleSensitive(isSensitive) {
580+
await this.$store.dispatch('toggleSensitive', { token: this.item.token, isSensitive })
581+
},
582+
532583
onClick() {
533584
// add as temporary item that will refresh after the joining process is complete
534585
if (this.isSearchResult) {

src/store/conversationsStore.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ import {
3535
createConversation,
3636
addToFavorites,
3737
removeFromFavorites,
38+
markAsImportant,
39+
markAsUnimportant,
40+
markAsSensitive,
41+
markAsInsensitive,
3842
archiveConversation,
3943
unarchiveConversation,
4044
fetchConversations,
@@ -581,6 +585,36 @@ const actions = {
581585
}
582586
},
583587

588+
async toggleImportant(context, { token, isImportant }) {
589+
if (!context.getters.conversations[token]) {
590+
return
591+
}
592+
593+
try {
594+
const response = isImportant
595+
? await markAsImportant(token)
596+
: await markAsUnimportant(token)
597+
context.commit('addConversation', response.data.ocs.data)
598+
} catch (error) {
599+
console.error('Error while changing the conversation important status: ', error)
600+
}
601+
},
602+
603+
async toggleSensitive(context, { token, isSensitive }) {
604+
if (!context.getters.conversations[token]) {
605+
return
606+
}
607+
608+
try {
609+
const response = isSensitive
610+
? await markAsSensitive(token)
611+
: await markAsInsensitive(token)
612+
context.commit('addConversation', response.data.ocs.data)
613+
} catch (error) {
614+
console.error('Error while changing the conversation sensitive status: ', error)
615+
}
616+
},
617+
584618
async toggleLobby({ commit, getters }, { token, enableLobby }) {
585619
if (!getters.conversations[token]) {
586620
return

0 commit comments

Comments
 (0)