File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1010 *
1111 * @flow
1212 */
13- import { app , BrowserWindow , ipcMain } from 'electron' ;
13+ import { app , BrowserWindow , ipcMain , systemPreferences } from 'electron' ;
1414import { autoUpdater } from 'electron-updater' ;
1515import log from 'electron-log' ;
1616import MenuBuilder from './menu' ;
1717import { CliLocal } from './mainProcess/cliLocal' ;
1818import fs from "fs" ;
19- import { GUI_LOG_FILE } from './const' ;
19+ import { GUI_LOG_FILE , IPC_CAMERA } from './const' ;
2020
2121
2222export default class AppUpdater {
@@ -91,6 +91,20 @@ else {
9191 }
9292 } ) ;
9393
94+ ipcMain . on ( IPC_CAMERA . REQUEST , async ( event ) => {
95+ if ( process . platform !== 'darwin' || systemPreferences . getMediaAccessStatus ( "camera" ) !== "granted" ) {
96+ event . reply ( IPC_CAMERA . GRANTED )
97+ } else {
98+ const granted = await systemPreferences . askForMediaAccess ( "camera" ) ;
99+
100+ if ( granted ) {
101+ event . reply ( IPC_CAMERA . GRANTED )
102+ } else {
103+ event . reply ( IPC_CAMERA . DENIED )
104+ }
105+ }
106+ } ) ;
107+
94108 // init cliLocal
95109 const guiLogStream = fs . createWriteStream ( GUI_LOG_FILE , { flags : 'a' } )
96110 new CliLocal ( ipcMain , mainWindow . webContents , guiLogStream )
You can’t perform that action at this time.
0 commit comments