From c9eac69e2970b2e2806509a8d4ee279acd3544f5 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Mon, 7 Oct 2024 09:45:59 +0200 Subject: [PATCH] feat(devices): add an option to always disable steams by default before joining the call Signed-off-by: DorraJaouad --- .../ConversationSettingsDialog.vue | 15 ++++++++++- .../MediaSettings/MediaSettings.vue | 16 ++++++++++++ src/stores/settings.js | 26 ++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/components/ConversationSettings/ConversationSettingsDialog.vue b/src/components/ConversationSettings/ConversationSettingsDialog.vue index 07e1498d75a..c2f47edeeb6 100644 --- a/src/components/ConversationSettings/ConversationSettingsDialog.vue +++ b/src/components/ConversationSettings/ConversationSettingsDialog.vue @@ -27,6 +27,11 @@ @update:checked="setShowMediaSettings"> {{ t('spreed', 'Always show the device preview screen before joining a call in this conversation.') }} + + {{ t('spreed', 'Disable camera and microphone by default when joining a call in this conversation.') }} +

{{ t('spreed', 'The consent to be recorded will be required for each participant before joining every call.') }}

@@ -197,6 +202,10 @@ export default { return this.settingsStore.getShowMediaSettings(this.token) }, + cameraAndMicrophoneDefaultDisabled() { + return this.settingsStore.getCameraAndMicrophoneDefaultDisabled(this.token) + }, + conversation() { return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation }, @@ -273,7 +282,11 @@ export default { setShowMediaSettings(newValue) { this.settingsStore.setShowMediaSettings(this.token, newValue) - } + }, + + setCameraAndMicrophoneDefaultDisabled(newValue) { + this.settingsStore.setCameraAndMicrophoneDefaultDisabled(this.token, newValue) + }, }, } diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 5a0e72068df..86330079629 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -352,6 +352,10 @@ export default { return this.settingsStore.getShowMediaSettings(this.token) }, + cameraAndMicrophoneDefaultDisabled() { + return this.settingsStore.getCameraAndMicrophoneDefaultDisabled(this.token) + }, + showVideo() { return this.videoPreviewAvailable && this.videoOn }, @@ -539,7 +543,19 @@ export default { } }, + applyDefaultSettings() { + if (this.cameraAndMicrophoneDefaultDisabled) { + if (this.audioOn) { + this.toggleAudio() + } + if (this.videoOn) { + this.toggleVideo() + } + } + }, + closeModalAndApplySettings() { + this.applyDefaultSettings() if (this.updatedBackground) { this.handleUpdateBackground(this.updatedBackground) } diff --git a/src/stores/settings.js b/src/stores/settings.js index bfbfa416f20..533233b096c 100644 --- a/src/stores/settings.js +++ b/src/stores/settings.js @@ -33,7 +33,8 @@ export const useSettingsStore = defineStore('settings', { state: () => ({ readStatusPrivacy: loadState('spreed', 'read_status_privacy', PRIVACY.PRIVATE), typingStatusPrivacy: loadState('spreed', 'typing_privacy', PRIVACY.PRIVATE), - showMediaSettings: {} + showMediaSettings: {}, + cameraAndMicrophoneDefaultDisabled: {} }), getters: { @@ -65,6 +66,20 @@ export const useSettingsStore = defineStore('settings', { } } }, + + getCameraAndMicrophoneDefaultDisabled: (state) => (token) => { + if (!token) { + return false + } + + if (state.cameraAndMicrophoneDefaultDisabled[token] !== undefined) { + return state.cameraAndMicrophoneDefaultDisabled[token] + } + + const storedValue = BrowserStorage.getItem('cameraAndMicrophoneDefaultDisabled_' + token) + Vue.set(state.cameraAndMicrophoneDefaultDisabled, token, storedValue === 'true') + return storedValue === 'true' + } }, actions: { @@ -96,5 +111,14 @@ export const useSettingsStore = defineStore('settings', { } Vue.set(this.showMediaSettings, token, value) }, + + setCameraAndMicrophoneDefaultDisabled(token, value) { + if (value) { + BrowserStorage.setItem('cameraAndMicrophoneDefaultDisabled_' + token, 'true') + } else { + BrowserStorage.removeItem('cameraAndMicrophoneDefaultDisabled_' + token) + } + Vue.set(this.cameraAndMicrophoneDefaultDisabled, token, value) + } }, })