From 4601c0f1bb803c76ca543b821d582d4401b23e0f Mon Sep 17 00:00:00 2001 From: Thomas Zhou Date: Tue, 16 Aug 2022 00:09:11 -0700 Subject: [PATCH] #1095 Use different library for screen capture permission --- main/common/system-permissions.ts | 15 ++++++--------- package.json | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/main/common/system-permissions.ts b/main/common/system-permissions.ts index c60f5971..f8ae7cfa 100644 --- a/main/common/system-permissions.ts +++ b/main/common/system-permissions.ts @@ -1,5 +1,5 @@ import {systemPreferences, shell, dialog, app} from 'electron'; -const {hasScreenCapturePermission, hasPromptedForPermission} = require('mac-screen-capture-permissions'); +import {getAuthStatus, askForScreenCaptureAccess} from 'node-mac-permissions'; const {ensureDockIsShowing} = require('../utils/dock'); let isDialogShowing = false; @@ -73,17 +73,14 @@ const screenCaptureFallback = promptSystemPreferences({ }); export const ensureScreenCapturePermissions = (fallback = screenCaptureFallback) => { - const hadAsked = hasPromptedForPermission(); - - const hasAccess = hasScreenCapturePermission(); - - if (hasAccess) { + const status = getAuthStatus('screen'); + if (status === 'authorized') { return true; } - fallback({hasAsked: !hadAsked}); + askForScreenCaptureAccess(); + fallback(); return false; }; -export const hasScreenCaptureAccess = () => hasScreenCapturePermission(); - +export const hasScreenCaptureAccess = () => getAuthStatus('screen') === 'authorized'; diff --git a/package.json b/package.json index 8ee0fe54..73464fb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "is-online": "^8.4.0", "lodash": "^4.17.21", "mac-open-with": "^1.2.3", - "mac-screen-capture-permissions": "^1.1.0", "mac-windows": "^1.0.0", "macos-audio-devices": "^1.4.0", "macos-version": "^5.2.1", @@ -69,6 +68,7 @@ "move-file": "^2.0.0", "nearest-normal-aspect-ratio": "^1.2.1", "node-mac-app-icon": "^1.4.0", + "node-mac-permissions": "^2.2.1", "object-hash": "^2.1.1", "p-cancelable": "^2.1.0", "p-event": "^4.2.0",