mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 15:26:59 +08:00
fix(electron): use askForMeetingPermission for asking microphone permission (#11792)
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user