diff options
Diffstat (limited to 'src/electron/macOSPermissions.js')
-rw-r--r-- | src/electron/macOSPermissions.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/electron/macOSPermissions.js b/src/electron/macOSPermissions.js index 940b16c6e..c114f4843 100644 --- a/src/electron/macOSPermissions.js +++ b/src/electron/macOSPermissions.js | |||
@@ -2,18 +2,15 @@ import { app, systemPreferences, dialog } from 'electron'; | |||
2 | import fs from 'fs'; | 2 | import fs from 'fs'; |
3 | import macosVersion from 'macos-version'; | 3 | import macosVersion from 'macos-version'; |
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | import { isMac } from '../environment'; | 5 | import { askForScreenCaptureAccess } from 'node-mac-permissions'; |
6 | |||
7 | let askForScreenCaptureAccess; | ||
8 | if (isMac) { | ||
9 | // eslint-disable-next-line global-require | ||
10 | askForScreenCaptureAccess = require('node-mac-permissions').askForScreenCaptureAccess; | ||
11 | } | ||
12 | 6 | ||
13 | const debug = require('debug')('Ferdi:macOSPermissions'); | 7 | const debug = require('debug')('Ferdi:macOSPermissions'); |
14 | 8 | ||
15 | const permissionExists = macosVersion.isGreaterThanOrEqualTo('10.15'); | 9 | const permissionExists = macosVersion.isGreaterThanOrEqualTo('10.15'); |
16 | const filePath = path.join(app.getPath('userData'), '.has-app-requested-screen-capture-permissions'); | 10 | const filePath = path.join( |
11 | app.getPath('userData'), | ||
12 | '.has-app-requested-screen-capture-permissions', | ||
13 | ); | ||
17 | 14 | ||
18 | function hasPromptedForPermission() { | 15 | function hasPromptedForPermission() { |
19 | if (!permissionExists) { | 16 | if (!permissionExists) { |
@@ -49,7 +46,7 @@ function createStatusFile() { | |||
49 | } | 46 | } |
50 | } | 47 | } |
51 | 48 | ||
52 | export default async function (mainWindow) { | 49 | export const askFormacOSPermissions = async mainWindow => { |
53 | debug('Checking camera & microphone permissions'); | 50 | debug('Checking camera & microphone permissions'); |
54 | systemPreferences.askForMediaAccess('camera'); | 51 | systemPreferences.askForMediaAccess('camera'); |
55 | systemPreferences.askForMediaAccess('microphone'); | 52 | systemPreferences.askForMediaAccess('microphone'); |
@@ -60,24 +57,20 @@ export default async function (mainWindow) { | |||
60 | const { response } = await dialog.showMessageBox(mainWindow, { | 57 | const { response } = await dialog.showMessageBox(mainWindow, { |
61 | type: 'info', | 58 | type: 'info', |
62 | message: 'Enable Screen Sharing', | 59 | message: 'Enable Screen Sharing', |
63 | detail: 'To enable screen sharing for some services, Ferdi needs the permission to record your screen.', | 60 | detail: |
64 | buttons: [ | 61 | 'To enable screen sharing for some services, Ferdi needs the permission to record your screen.', |
65 | 'Allow screen sharing', | 62 | buttons: ['Allow screen sharing', 'No', 'Ask me later'], |
66 | 'No', | ||
67 | 'Ask me later', | ||
68 | ], | ||
69 | defaultId: 0, | 63 | defaultId: 0, |
70 | cancelId: 2, | 64 | cancelId: 2, |
71 | }); | 65 | }); |
72 | 66 | ||
73 | console.log('result', response); | ||
74 | if (response === 0) { | 67 | if (response === 0) { |
75 | debug('Asking for access'); | 68 | debug('Asking for access'); |
76 | askForScreenCaptureAccess(); | 69 | askForScreenCaptureAccess(); |
77 | createStatusFile(); | 70 | createStatusFile(); |
78 | } else if (response === 1) { | 71 | } else if (response === 1) { |
79 | debug('Don\'t ask again'); | 72 | debug("Don't ask again"); |
80 | createStatusFile(); | 73 | createStatusFile(); |
81 | } | 74 | } |
82 | } | 75 | } |
83 | } | 76 | }; |