From c415c715a5e977ae8dbb5dc7303451aeda220966 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Fri, 30 Jul 2021 16:44:01 +1000 Subject: [PATCH] added access to camera check --- js/background.js | 2 +- main.js | 14 ++++++++++---- preload.js | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/background.js b/js/background.js index 7590cc360..d4474995c 100644 --- a/js/background.js +++ b/js/background.js @@ -340,7 +340,7 @@ window.toggleMediaPermissions = async () => { const value = window.getMediaPermissions(); if (value === false && Signal.OS.isMacOS()) { - await window.askForMicrophoneAccess(); + await window.askForMediaAccess(); } window.setMediaPermissions(!value); }; diff --git a/main.js b/main.js index 8fc09e8d4..da5b4c5ca 100644 --- a/main.js +++ b/main.js @@ -985,13 +985,19 @@ function getThemeFromMainWindow() { }); } -function askForMicrophoneAccess() { - const status = systemPreferences.getMediaAccessStatus('microphone'); +function askForMediaAccess() { + // Microphone part + let status = systemPreferences.getMediaAccessStatus('microphone'); if (status !== 'granted') { systemPreferences.askForMediaAccess('microphone'); } + // Camera part + status = systemPreferences.getMediaAccessStatus('camera'); + if (status !== 'granted') { + systemPreferences.askForMediaAccess('camera'); + } } -ipc.on('microphone-access', () => { - askForMicrophoneAccess(); +ipc.on('media-access', () => { + askForMediaAccess(); }); diff --git a/preload.js b/preload.js index d185c023d..6904d80ab 100644 --- a/preload.js +++ b/preload.js @@ -219,7 +219,7 @@ window.setSettingValue = (settingID, value) => { window.getMediaPermissions = () => ipc.sendSync('get-media-permissions'); window.setMediaPermissions = value => ipc.send('set-media-permissions', !!value); -window.askForMicrophoneAccess = () => ipc.send('microphone-access'); +window.askForMediaAccess = () => ipc.send('media-access'); // Auto update setting window.getAutoUpdateEnabled = () => ipc.sendSync('get-auto-update-setting');