fix(electron): use askForMeetingPermission for asking microphone permission (#11792)

This commit is contained in:
pengx17
2025-04-21 07:37:43 +00:00
parent f87a6e17bd
commit 2bd9cfe20a
4 changed files with 24 additions and 1 deletions

View File

@@ -780,6 +780,13 @@ export const checkMeetingPermissions = () => {
) as Record<(typeof mediaTypes)[number], boolean>;
};
export const askForMeetingPermission = async (type: 'microphone') => {
if (!isMacOS()) {
return false;
}
return systemPreferences.askForMediaAccess(type);
};
export const checkCanRecordMeeting = () => {
const features = checkMeetingPermissions();
return (

View File

@@ -9,6 +9,7 @@ import { shell } from 'electron';
import { isMacOS } from '../../shared/utils';
import type { NamespaceHandlers } from '../type';
import {
askForMeetingPermission,
checkMeetingPermissions,
checkRecordingAvailable,
disableRecordingFeature,
@@ -76,6 +77,9 @@ export const recordingHandlers = {
checkMeetingPermissions: async () => {
return checkMeetingPermissions();
},
askForMeetingPermission: async (_, type: 'microphone') => {
return askForMeetingPermission(type);
},
showRecordingPermissionSetting: async (_, type: 'screen' | 'microphone') => {
const urlMap = {
screen: 'Privacy_ScreenCapture',

View File

@@ -210,7 +210,13 @@ export const MeetingsSettings = () => {
const handleOpenMicrophoneRecordingPermissionSetting =
useAsyncCallback(async () => {
await meetingSettingsService.showRecordingPermissionSetting('microphone');
const result =
await meetingSettingsService.askForMeetingPermission('microphone');
if (!result) {
await meetingSettingsService.showRecordingPermissionSetting(
'microphone'
);
}
}, [meetingSettingsService]);
const handleOpenSavedRecordings = useAsyncCallback(async () => {

View File

@@ -114,6 +114,12 @@ export class MeetingSettingsService extends Service {
);
}
async askForMeetingPermission(type: 'microphone') {
return this.desktopApiService?.handler.recording.askForMeetingPermission(
type
);
}
setRecordingMode = (mode: MeetingSettingsSchema['recordingMode']) => {
const currentMode = this.settings.recordingMode;