diff options
Diffstat (limited to 'src/electron')
-rw-r--r-- | src/electron/ipc-api/download.ts | 7 | ||||
-rw-r--r-- | src/electron/ipc-api/sessionStorage.ts | 9 | ||||
-rw-r--r-- | src/electron/macOSPermissions.ts | 19 |
3 files changed, 19 insertions, 16 deletions
diff --git a/src/electron/ipc-api/download.ts b/src/electron/ipc-api/download.ts index cb2aa7383..3631e8fee 100644 --- a/src/electron/ipc-api/download.ts +++ b/src/electron/ipc-api/download.ts | |||
@@ -4,7 +4,8 @@ import mime from 'mime-types'; | |||
4 | import { writeFileSync } from 'fs-extra'; | 4 | import { writeFileSync } from 'fs-extra'; |
5 | import { PathLike } from 'fs'; | 5 | import { PathLike } from 'fs'; |
6 | 6 | ||
7 | const debug = require('debug')('Ferdium:ipcApi:download'); | 7 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
8 | // const debug = require('debug')('Ferdium:ipcApi:download'); | ||
8 | 9 | ||
9 | function decodeBase64Image(dataString: string) { | 10 | function decodeBase64Image(dataString: string) { |
10 | const matches = dataString.match(/^data:([+/A-Za-z-]+);base64,(.+)$/); | 11 | const matches = dataString.match(/^data:([+/A-Za-z-]+);base64,(.+)$/); |
@@ -27,7 +28,7 @@ export default (params: { mainWindow: BrowserWindow }) => { | |||
27 | const dl = await download(win!, url, { | 28 | const dl = await download(win!, url, { |
28 | saveAs: true, | 29 | saveAs: true, |
29 | }); | 30 | }); |
30 | debug('File saved to', dl.savePath); | 31 | console.log('File saved to', dl.savePath); |
31 | } else { | 32 | } else { |
32 | const extension = mime.extension(fileOptions.mime); | 33 | const extension = mime.extension(fileOptions.mime); |
33 | const filename = `${fileOptions.name}.${extension}`; | 34 | const filename = `${fileOptions.name}.${extension}`; |
@@ -46,7 +47,7 @@ export default (params: { mainWindow: BrowserWindow }) => { | |||
46 | 'binary', | 47 | 'binary', |
47 | ); | 48 | ); |
48 | 49 | ||
49 | debug('File blob saved to', saveDialog.filePath); | 50 | console.log('File blob saved to', saveDialog.filePath); |
50 | } catch (error) { | 51 | } catch (error) { |
51 | console.error(error); | 52 | console.error(error); |
52 | } | 53 | } |
diff --git a/src/electron/ipc-api/sessionStorage.ts b/src/electron/ipc-api/sessionStorage.ts index 20f0ac9d2..96acacd12 100644 --- a/src/electron/ipc-api/sessionStorage.ts +++ b/src/electron/ipc-api/sessionStorage.ts | |||
@@ -2,7 +2,8 @@ import { ipcMain, Session, session } from 'electron'; | |||
2 | 2 | ||
3 | import { TODOS_PARTITION_ID } from '../../config'; | 3 | import { TODOS_PARTITION_ID } from '../../config'; |
4 | 4 | ||
5 | const debug = require('debug')('Ferdium:ipcApi:sessionStorage'); | 5 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
6 | // const debug = require('debug')('Ferdium:ipcApi:sessionStorage'); | ||
6 | 7 | ||
7 | function deduceSession(serviceId: string | undefined | null): Session { | 8 | function deduceSession(serviceId: string | undefined | null): Session { |
8 | if (serviceId) { | 9 | if (serviceId) { |
@@ -21,14 +22,14 @@ export default async () => { | |||
21 | const serviceSession = deduceSession(serviceId); | 22 | const serviceSession = deduceSession(serviceId); |
22 | serviceSession.flushStorageData(); | 23 | serviceSession.flushStorageData(); |
23 | if (targetsToClear) { | 24 | if (targetsToClear) { |
24 | debug('Clearing targets:', targetsToClear); | 25 | console.log('Clearing targets:', targetsToClear); |
25 | serviceSession.clearStorageData(targetsToClear); | 26 | serviceSession.clearStorageData(targetsToClear); |
26 | } else { | 27 | } else { |
27 | debug('Clearing all targets'); | 28 | console.log('Clearing all targets'); |
28 | serviceSession.clearStorageData(); | 29 | serviceSession.clearStorageData(); |
29 | } | 30 | } |
30 | } catch (error) { | 31 | } catch (error) { |
31 | debug(error); | 32 | console.log(error); |
32 | } | 33 | } |
33 | }); | 34 | }); |
34 | 35 | ||
diff --git a/src/electron/macOSPermissions.ts b/src/electron/macOSPermissions.ts index 7e4bb3c4d..07caaaada 100644 --- a/src/electron/macOSPermissions.ts +++ b/src/electron/macOSPermissions.ts | |||
@@ -6,11 +6,12 @@ import { dirname } from 'path'; | |||
6 | import { askForScreenCaptureAccess } from 'node-mac-permissions'; | 6 | import { askForScreenCaptureAccess } from 'node-mac-permissions'; |
7 | import { userDataPath } from '../environment-remote'; | 7 | import { userDataPath } from '../environment-remote'; |
8 | 8 | ||
9 | const debug = require('debug')('Ferdium:macOSPermissions'); | 9 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
10 | // const debug = require('debug')('Ferdium:macOSPermissions'); | ||
10 | 11 | ||
11 | const isExplicitScreenCapturePermissionReqd = | 12 | const isExplicitScreenCapturePermissionReqd = |
12 | macosVersion.isGreaterThanOrEqualTo('10.15'); | 13 | macosVersion.isGreaterThanOrEqualTo('10.15'); |
13 | debug( | 14 | console.log( |
14 | `Should check explicitly for screen-capture permissions: ${isExplicitScreenCapturePermissionReqd}`, | 15 | `Should check explicitly for screen-capture permissions: ${isExplicitScreenCapturePermissionReqd}`, |
15 | ); | 16 | ); |
16 | 17 | ||
@@ -21,7 +22,7 @@ function hasPromptedForScreenCapturePermission(): string | boolean { | |||
21 | return false; | 22 | return false; |
22 | } | 23 | } |
23 | 24 | ||
24 | debug('Checking if status file exists'); | 25 | console.log('Checking if status file exists'); |
25 | return filePath && pathExistsSync(filePath); | 26 | return filePath && pathExistsSync(filePath); |
26 | } | 27 | } |
27 | 28 | ||
@@ -31,7 +32,7 @@ function hasScreenCapturePermissionAlreadyBeenGranted(): boolean { | |||
31 | } | 32 | } |
32 | 33 | ||
33 | const screenCaptureStatus = systemPreferences.getMediaAccessStatus('screen'); | 34 | const screenCaptureStatus = systemPreferences.getMediaAccessStatus('screen'); |
34 | debug(`screen-capture permissions status: ${screenCaptureStatus}`); | 35 | console.log(`screen-capture permissions status: ${screenCaptureStatus}`); |
35 | return screenCaptureStatus === 'granted'; | 36 | return screenCaptureStatus === 'granted'; |
36 | } | 37 | } |
37 | 38 | ||
@@ -49,18 +50,18 @@ function createStatusFile() { | |||
49 | } | 50 | } |
50 | 51 | ||
51 | export const askFormacOSPermissions = async (mainWindow: BrowserWindow) => { | 52 | export const askFormacOSPermissions = async (mainWindow: BrowserWindow) => { |
52 | debug('Checking camera & microphone permissions'); | 53 | console.log('Checking camera & microphone permissions'); |
53 | systemPreferences.askForMediaAccess('camera'); | 54 | systemPreferences.askForMediaAccess('camera'); |
54 | systemPreferences.askForMediaAccess('microphone'); | 55 | systemPreferences.askForMediaAccess('microphone'); |
55 | 56 | ||
56 | if (hasScreenCapturePermissionAlreadyBeenGranted()) { | 57 | if (hasScreenCapturePermissionAlreadyBeenGranted()) { |
57 | debug('Already obtained screen-capture permissions - writing status file'); | 58 | console.log('Already obtained screen-capture permissions - writing status file'); |
58 | createStatusFile(); | 59 | createStatusFile(); |
59 | return; | 60 | return; |
60 | } | 61 | } |
61 | 62 | ||
62 | if (!hasPromptedForScreenCapturePermission()) { | 63 | if (!hasPromptedForScreenCapturePermission()) { |
63 | debug('Checking screen capture permissions'); | 64 | console.log('Checking screen capture permissions'); |
64 | 65 | ||
65 | const { response } = await dialog.showMessageBox(mainWindow, { | 66 | const { response } = await dialog.showMessageBox(mainWindow, { |
66 | type: 'info', | 67 | type: 'info', |
@@ -73,11 +74,11 @@ export const askFormacOSPermissions = async (mainWindow: BrowserWindow) => { | |||
73 | }); | 74 | }); |
74 | 75 | ||
75 | if (response === 0) { | 76 | if (response === 0) { |
76 | debug('Asking for access'); | 77 | console.log('Asking for access'); |
77 | askForScreenCaptureAccess(); | 78 | askForScreenCaptureAccess(); |
78 | createStatusFile(); | 79 | createStatusFile(); |
79 | } else if (response === 1) { | 80 | } else if (response === 1) { |
80 | debug("Don't ask again"); | 81 | console.log("Don't ask again"); |
81 | createStatusFile(); | 82 | createStatusFile(); |
82 | } | 83 | } |
83 | } | 84 | } |