mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-30 11:26:24 +02:00
switch to on-demand permission requests and improve suggestion UX
This commit is contained in:
parent
aeb3f13f91
commit
c5aa869adb
12 changed files with 195 additions and 89 deletions
|
|
@ -4,6 +4,7 @@ type PermissionStatus = 'authorized' | 'denied' | 'not determined' | 'restricted
|
|||
|
||||
export interface PermissionsStatus {
|
||||
accessibility: PermissionStatus;
|
||||
screenRecording: PermissionStatus;
|
||||
}
|
||||
|
||||
function isMac(): boolean {
|
||||
|
|
@ -16,18 +17,19 @@ function getNodeMacPermissions() {
|
|||
|
||||
export function getPermissionsStatus(): PermissionsStatus {
|
||||
if (!isMac()) {
|
||||
return { accessibility: 'authorized' };
|
||||
return { accessibility: 'authorized', screenRecording: 'authorized' };
|
||||
}
|
||||
|
||||
const perms = getNodeMacPermissions();
|
||||
return {
|
||||
accessibility: perms.getAuthStatus('accessibility'),
|
||||
screenRecording: perms.getAuthStatus('screen'),
|
||||
};
|
||||
}
|
||||
|
||||
export function allPermissionsGranted(): boolean {
|
||||
const status = getPermissionsStatus();
|
||||
return status.accessibility === 'authorized';
|
||||
return status.accessibility === 'authorized' && status.screenRecording === 'authorized';
|
||||
}
|
||||
|
||||
export function requestAccessibility(): void {
|
||||
|
|
@ -36,6 +38,18 @@ export function requestAccessibility(): void {
|
|||
perms.askForAccessibilityAccess();
|
||||
}
|
||||
|
||||
export function hasScreenRecordingPermission(): boolean {
|
||||
if (!isMac()) return true;
|
||||
const perms = getNodeMacPermissions();
|
||||
return perms.getAuthStatus('screen') === 'authorized';
|
||||
}
|
||||
|
||||
export function requestScreenRecording(): void {
|
||||
if (!isMac()) return;
|
||||
const perms = getNodeMacPermissions();
|
||||
perms.askForScreenCaptureAccess();
|
||||
}
|
||||
|
||||
export function restartApp(): void {
|
||||
app.relaunch();
|
||||
app.exit(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue