fix(electron): optimize meeting privacy settings (#12530)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Added support for requesting screen recording permission on macOS in addition to microphone permission.
  - Introduced a new "Permission issues" section in meeting privacy settings, including a button to restart the app if permission status is not updated.
- **Improvements**
  - Unified permission handling for screen and microphone settings, simplifying the user experience.
  - Added new localized strings for enhanced clarity regarding permission issues and app restart instructions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
pengx17
2025-05-27 11:08:06 +00:00
parent d6476db64d
commit 4ad008f712
6 changed files with 74 additions and 29 deletions

View File

@@ -471,6 +471,21 @@ function setupMediaListeners() {
);
}
function askForScreenRecordingPermission() {
if (!isMacOS()) {
return false;
}
try {
const ShareableContent = require('@affine/native').ShareableContent;
// this will trigger the permission prompt
new ShareableContent();
return true;
} catch (error) {
logger.error('failed to ask for screen recording permission', error);
}
return false;
}
// will be called when the app is ready or when the user has enabled the recording feature in settings
export function setupRecordingFeature() {
if (!MeetingsSettingsState.value.enabled || !checkCanRecordMeeting()) {
@@ -788,10 +803,15 @@ export const checkMeetingPermissions = () => {
) as Record<(typeof mediaTypes)[number], boolean>;
};
export const askForMeetingPermission = async (type: 'microphone') => {
export const askForMeetingPermission = async (
type: 'microphone' | 'screen'
) => {
if (!isMacOS()) {
return false;
}
if (type === 'screen') {
return askForScreenRecordingPermission();
}
return systemPreferences.askForMediaAccess(type);
};

View File

@@ -77,18 +77,17 @@ export const recordingHandlers = {
checkMeetingPermissions: async () => {
return checkMeetingPermissions();
},
askForMeetingPermission: async (_, type: 'microphone') => {
askForMeetingPermission: async (_, type: 'screen' | 'microphone') => {
return askForMeetingPermission(type);
},
showRecordingPermissionSetting: async (_, type: 'screen' | 'microphone') => {
const urlMap = {
screen: 'Privacy_ScreenCapture',
microphone: 'Privacy_Microphone',
};
if (isMacOS()) {
return shell.openExternal(
`x-apple.systempreferences:com.apple.preference.security?${urlMap[type]}`
);
const urlMap = {
screen: 'Privacy_ScreenCapture',
microphone: 'Privacy_Microphone',
};
const url = `x-apple.systempreferences:com.apple.preference.security?${urlMap[type]}`;
return shell.openExternal(url);
}
// this only available on MacOS
return false;