Skip to content

Commit

Permalink
feat(devices): add an option to always disable steams by default befo…
Browse files Browse the repository at this point in the history
…re joining the call

Signed-off-by: DorraJaouad <[email protected]>
  • Loading branch information
DorraJaouad committed Oct 7, 2024
1 parent b681d0e commit c9eac69
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
@update:checked="setShowMediaSettings">
{{ t('spreed', 'Always show the device preview screen before joining a call in this conversation.') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch type="switch"
:checked="cameraAndMicrophoneDefaultDisabled"
@update:checked="setCameraAndMicrophoneDefaultDisabled">
{{ t('spreed', 'Disable camera and microphone by default when joining a call in this conversation.') }}
</NcCheckboxRadioSwitch>
<p v-if="recordingConsentRequired">
{{ t('spreed', 'The consent to be recorded will be required for each participant before joining every call.') }}
</p>
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -273,7 +282,11 @@ export default {
setShowMediaSettings(newValue) {
this.settingsStore.setShowMediaSettings(this.token, newValue)
}
},
setCameraAndMicrophoneDefaultDisabled(newValue) {
this.settingsStore.setCameraAndMicrophoneDefaultDisabled(this.token, newValue)
},
},
}
</script>
Expand Down
16 changes: 16 additions & 0 deletions src/components/MediaSettings/MediaSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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)
}
Expand Down
26 changes: 25 additions & 1 deletion src/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
}
},
})

0 comments on commit c9eac69

Please sign in to comment.