Skip to content

Commit

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

Signed-off-by: DorraJaouad <[email protected]>
  • Loading branch information
DorraJaouad committed Oct 8, 2024
1 parent af917bc commit 7335048
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/components/CallView/shared/LocalAudioControlButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import VolumeIndicator from '../../UIShared/VolumeIndicator.vue'
import { PARTICIPANT } from '../../../constants.js'
import BrowserStorage from '../../../services/BrowserStorage.js'
import { useSettingsStore } from '../../../stores/settings.js'
export default {
name: 'LocalAudioControlButton',
Expand Down Expand Up @@ -67,6 +68,12 @@ export default {
},
},
setup() {
return {
storeSettings: useSettingsStore(),
}
},
computed: {
isAudioAllowed() {
return this.conversation.permissions & PARTICIPANT.PERMISSIONS.PUBLISH_AUDIO
Expand Down Expand Up @@ -109,6 +116,10 @@ export default {
? t('spreed', 'Mute audio')
: t('spreed', 'Unmute audio')
},
mediaDefaultStateEnabled() {
return this.storeSettings.mediaDefaultState
},
},
created() {
Expand All @@ -118,6 +129,9 @@ export default {
mounted() {
subscribe('local-audio-control-button:toggle-audio', this.updateDeviceState)
if (this.mediaDefaultStateEnabled) {
this.model.disableAudio()
}
},
beforeDestroy() {
Expand Down
14 changes: 14 additions & 0 deletions src/components/CallView/shared/LocalVideoControlButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useHotKey } from '@nextcloud/vue/dist/Composables/useHotKey.js'
import { PARTICIPANT } from '../../../constants.js'
import BrowserStorage from '../../../services/BrowserStorage.js'
import { useSettingsStore } from '../../../stores/settings.js'
export default {
name: 'LocalVideoControlButton',
Expand Down Expand Up @@ -66,6 +67,12 @@ export default {
},
},
setup() {
return {
storeSettings: useSettingsStore(),
}
},
computed: {
isVideoAllowed() {
return this.conversation.permissions & PARTICIPANT.PERMISSIONS.PUBLISH_VIDEO
Expand Down Expand Up @@ -116,6 +123,10 @@ export default {
return t('spreed', 'Enable video. Your connection will be briefly interrupted when enabling the video for the first time')
},
mediaDefaultStateEnabled() {
return this.storeSettings.mediaDefaultState
},
},
created() {
Expand All @@ -124,6 +135,9 @@ export default {
mounted() {
subscribe('local-video-control-button:toggle-video', this.updateDeviceState)
if (this.mediaDefaultStateEnabled) {
this.model.disableVideo()
}
},
beforeDestroy() {
Expand Down
29 changes: 29 additions & 0 deletions src/components/SettingsDialog/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@
{{ t('spreed', 'Sounds for chat and call notifications can be adjusted in the personal settings.') }} ↗
</a>
</NcAppSettingsSection>
<NcAppSettingsSection id="calls"
:name="t('spreed', 'Calls')"
class="app-settings-section">
<NcCheckboxRadioSwitch id="call-media"
:checked="mediaDefaultStateEnabled"
:disabled="mediaLoading"
type="switch"
class="checkbox"
@update:checked="toggleMediaDefaultState">
{{ t('spreed', 'Turn off camera and microphone by default when joining a call') }}
</NcCheckboxRadioSwitch>
</NcAppSettingsSection>
<NcAppSettingsSection id="performance"
:name="t('spreed', 'Performance')"
class="app-settings-section">
Expand Down Expand Up @@ -235,6 +247,7 @@ export default {
attachmentFolderLoading: true,
privacyLoading: false,
playSoundsLoading: false,
mediaLoading: false,
}
},
Expand Down Expand Up @@ -263,6 +276,10 @@ export default {
return this.settingsStore.typingStatusPrivacy === PRIVACY.PUBLIC
},
mediaDefaultStateEnabled() {
return this.settingsStore.mediaDefaultState
},
settingsUrl() {
return generateUrl('/settings/user/notifications')
},
Expand Down Expand Up @@ -362,6 +379,18 @@ export default {
this.playSoundsLoading = false
},
async toggleMediaDefaultState(value) {
this.mediaLoading = true
try {
await this.settingsStore.setMediaDefaultState(value)
showSuccess(t('spreed', 'Your default media state has been saved'))
} catch (exception) {
showError(t('spreed', 'Error while setting default media state'))
} finally {
this.mediaLoading = false
}
},
handleShowSettings() {
this.showSettings = true
},
Expand Down
6 changes: 6 additions & 0 deletions src/services/settingsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ const setPlaySounds = async function(hasUserAccount, value) {
}
}

const setMediaDefaultState = async function(value) {
await axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/spreed/calls_start_without_media'),
{ configValue: value ? 'yes' : 'no' })
}

export {
setAttachmentFolder,
setReadStatusPrivacy,
setTypingStatusPrivacy,
setSIPSettings,
setPlaySounds,
setMediaDefaultState,
}
16 changes: 14 additions & 2 deletions src/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { loadState } from '@nextcloud/initial-state'

import { PRIVACY } from '../constants.js'
import BrowserStorage from '../services/BrowserStorage.js'
import { setReadStatusPrivacy, setTypingStatusPrivacy } from '../services/settingsService.js'
import { getTalkConfig } from '../services/CapabilitiesManager.ts'
import {
setReadStatusPrivacy,
setTypingStatusPrivacy,
setMediaDefaultState
} from '../services/settingsService.js'

/**
* @typedef {string} Token
Expand All @@ -33,7 +38,8 @@ export const useSettingsStore = defineStore('settings', {
state: () => ({
readStatusPrivacy: loadState('spreed', 'read_status_privacy', PRIVACY.PRIVATE),
typingStatusPrivacy: loadState('spreed', 'typing_privacy', PRIVACY.PRIVATE),
showMediaSettings: {}
showMediaSettings: {},
mediaDefaultState: getTalkConfig('local', 'call', 'start-without-media'),
}),

getters: {
Expand Down Expand Up @@ -96,5 +102,11 @@ export const useSettingsStore = defineStore('settings', {
}
Vue.set(this.showMediaSettings, token, value)
},

async setMediaDefaultState(value) {
await setMediaDefaultState(value)
this.mediaDefaultState = value

},
},
})

0 comments on commit 7335048

Please sign in to comment.