From 29bc85eb52b15d7e898f1159fe90eea535bc2dc3 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Tue, 8 Oct 2024 14:33:06 +0200 Subject: [PATCH 1/2] feat(devices): add an option to always disable srteams by default before joining the call Signed-off-by: DorraJaouad --- src/components/CallView/CallView.vue | 7 +++++ .../SettingsDialog/SettingsDialog.vue | 29 +++++++++++++++++++ src/services/settingsService.js | 6 ++++ src/stores/__tests__/settings.spec.js | 16 ++++++---- src/stores/settings.js | 15 ++++++++-- 5 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/components/CallView/CallView.vue b/src/components/CallView/CallView.vue index f6366974542..d961643244b 100644 --- a/src/components/CallView/CallView.vue +++ b/src/components/CallView/CallView.vue @@ -154,6 +154,7 @@ import { SIMULCAST } from '../../constants.js' import { fetchPeers } from '../../services/callsService.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { EventBus } from '../../services/EventBus.js' +import { useSettingsStore } from '../../stores/settings.js' import { localMediaModel, localCallParticipantModel, callParticipantCollection } from '../../utils/webrtc/index.js' import RemoteVideoBlocker from '../../utils/webrtc/RemoteVideoBlocker.js' @@ -195,6 +196,12 @@ export default { provide('CallView:devModeEnabled', devMode) const screenshotMode = ref(false) provide('CallView:screenshotModeEnabled', screenshotMode) + const settingsStore = useSettingsStore() + const startWithoutMediaEnabled = settingsStore.startWithoutMedia + if (startWithoutMediaEnabled) { + localMediaModel.disableAudio() + localMediaModel.disableVideo() + } return { localMediaModel, diff --git a/src/components/SettingsDialog/SettingsDialog.vue b/src/components/SettingsDialog/SettingsDialog.vue index cc5a6ba5795..7aed84d658d 100644 --- a/src/components/SettingsDialog/SettingsDialog.vue +++ b/src/components/SettingsDialog/SettingsDialog.vue @@ -20,6 +20,14 @@ :name="t('spreed', 'Choose devices')" class="app-settings-section"> + + {{ t('spreed', 'Turn off camera and microphone by default when joining a call') }} + diff --git a/src/services/settingsService.js b/src/services/settingsService.js index 9d6f768d042..4ba063457ec 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -74,10 +74,16 @@ const setPlaySounds = async function(hasUserAccount, value) { } } +const setStartWithoutMedia = 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, + setStartWithoutMedia, } diff --git a/src/stores/__tests__/settings.spec.js b/src/stores/__tests__/settings.spec.js index c8f1cf2574d..baa9cbb8ba2 100644 --- a/src/stores/__tests__/settings.spec.js +++ b/src/stores/__tests__/settings.spec.js @@ -70,7 +70,9 @@ describe('settingsStore', () => { // Assert expect(results).toEqual([true, false]) - expect(BrowserStorage.getItem).not.toHaveBeenCalled() + // It's always called at least once : BrowserStorage.getItem('cachedConversations') + // +1 + expect(BrowserStorage.getItem).toHaveBeenCalledTimes(1) }) it('shows correct values received from BrowserStorage', () => { @@ -87,10 +89,11 @@ describe('settingsStore', () => { // Assert expect(results).toEqual([true, true, false]) - expect(BrowserStorage.getItem).toHaveBeenCalledTimes(3) - expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(1, 'showMediaSettings_token-1') - expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-2') - expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(3, 'showMediaSettings_token-3') + // It's always called at least once : BrowserStorage.getItem('cachedConversations') + expect(BrowserStorage.getItem).toHaveBeenCalledTimes(4) // 1 + 3 + expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-1') + expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(3, 'showMediaSettings_token-2') + expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(4, 'showMediaSettings_token-3') }) it('updates values correctly', async () => { @@ -106,7 +109,8 @@ describe('settingsStore', () => { // Assert expect(results).toEqual([false, true]) - expect(BrowserStorage.getItem).not.toHaveBeenCalled() + // It's always called at least once : BrowserStorage.getItem('cachedConversations') + expect(BrowserStorage.getItem).toHaveBeenCalledTimes(1) expect(BrowserStorage.setItem).toHaveBeenCalledTimes(2) expect(BrowserStorage.setItem).toHaveBeenNthCalledWith(1, 'showMediaSettings_token-1', 'false') expect(BrowserStorage.setItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-2', 'true') diff --git a/src/stores/settings.js b/src/stores/settings.js index bfbfa416f20..5eb93f533ef 100644 --- a/src/stores/settings.js +++ b/src/stores/settings.js @@ -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, + setStartWithoutMedia +} from '../services/settingsService.js' /** * @typedef {string} Token @@ -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: {}, + startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'), }), getters: { @@ -96,5 +102,10 @@ export const useSettingsStore = defineStore('settings', { } Vue.set(this.showMediaSettings, token, value) }, + + async setStartWithoutMedia(value) { + await setStartWithoutMedia(value) + this.startWithoutMedia = value + }, }, }) From 8c6d2f03bfcf275679bd82aa5222e3818843b78d Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 10 Oct 2024 12:31:03 +0200 Subject: [PATCH 2/2] feat(config): create standard service request for user config Signed-off-by: DorraJaouad --- .../SettingsDialog/SettingsDialog.vue | 6 +++--- src/services/settingsService.js | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/SettingsDialog/SettingsDialog.vue b/src/components/SettingsDialog/SettingsDialog.vue index 7aed84d658d..2d423d03cd9 100644 --- a/src/components/SettingsDialog/SettingsDialog.vue +++ b/src/components/SettingsDialog/SettingsDialog.vue @@ -204,6 +204,7 @@ import { PRIVACY } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useCustomSettings } from '../../services/SettingsAPI.ts' +import { setUserConfig } from '../../services/settingsService.js' import { useSettingsStore } from '../../stores/settings.js' import { useSoundsStore } from '../../stores/sounds.js' @@ -297,12 +298,11 @@ export default { }, }, - created() { + async created() { const blurred = BrowserStorage.getItem('background-blurred') if (blurred === 'false' && isBackgroundBlurred === '') { console.debug('Blur was disabled intentionally, propagating last choice to server') - axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/theming/force_enable_blur_filter'), - { configValue: 'no' }) + await setUserConfig('theming', 'force_enable_blur_filter', 'no') } BrowserStorage.removeItem('background-blurred') }, diff --git a/src/services/settingsService.js b/src/services/settingsService.js index 4ba063457ec..684e8a8babe 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -75,8 +75,20 @@ const setPlaySounds = async function(hasUserAccount, value) { } const setStartWithoutMedia = async function(value) { - await axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/spreed/calls_start_without_media'), - { configValue: value ? 'yes' : 'no' }) + await setUserConfig('spreed', 'calls_start_without_media', value ? 'yes' : 'no') +} + +/** + * Set user config using provisioning API + * + * @param {string} appId - app id + * @param {string} configKey - key of the config to set + * @param {string} configValue - value to set + */ +const setUserConfig = async function(appId, configKey, configValue) { + await axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/{appId}/{configKey}', { appId, configKey }), { + configValue, + }) } export { @@ -86,4 +98,5 @@ export { setSIPSettings, setPlaySounds, setStartWithoutMedia, + setUserConfig, }