mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-26 02:35:58 +08:00
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:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Button,
|
||||
IconButton,
|
||||
Menu,
|
||||
MenuItem,
|
||||
@@ -11,6 +12,7 @@ import {
|
||||
SettingWrapper,
|
||||
} from '@affine/component/setting-components';
|
||||
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
|
||||
import { DesktopApiService } from '@affine/core/modules/desktop-api';
|
||||
import { MeetingSettingsService } from '@affine/core/modules/media/services/meeting-settings';
|
||||
import type { MeetingSettingsSchema } from '@affine/electron/main/shared-state-schema';
|
||||
import { Trans, useI18n } from '@affine/i18n';
|
||||
@@ -133,6 +135,7 @@ const PermissionSettingRow = ({
|
||||
const MeetingsSettingsMain = () => {
|
||||
const t = useI18n();
|
||||
const meetingSettingsService = useService(MeetingSettingsService);
|
||||
const desktopApiService = useService(DesktopApiService);
|
||||
const settings = useLiveData(meetingSettingsService.settings$);
|
||||
const [recordingFeatureAvailable, setRecordingFeatureAvailable] =
|
||||
useState(false);
|
||||
@@ -175,26 +178,22 @@ const MeetingsSettingsMain = () => {
|
||||
[meetingSettingsService]
|
||||
);
|
||||
|
||||
const handleOpenScreenRecordingPermissionSetting =
|
||||
useAsyncCallback(async () => {
|
||||
await meetingSettingsService.showRecordingPermissionSetting('screen');
|
||||
}, [meetingSettingsService]);
|
||||
|
||||
const handleOpenMicrophoneRecordingPermissionSetting =
|
||||
useAsyncCallback(async () => {
|
||||
const result =
|
||||
await meetingSettingsService.askForMeetingPermission('microphone');
|
||||
if (!result) {
|
||||
await meetingSettingsService.showRecordingPermissionSetting(
|
||||
'microphone'
|
||||
);
|
||||
}
|
||||
}, [meetingSettingsService]);
|
||||
const handleOpenPermissionSetting = useAsyncCallback(
|
||||
async (type: 'screen' | 'microphone') => {
|
||||
await meetingSettingsService.askForMeetingPermission(type);
|
||||
await meetingSettingsService.showRecordingPermissionSetting(type);
|
||||
},
|
||||
[meetingSettingsService]
|
||||
);
|
||||
|
||||
const handleOpenSavedRecordings = useAsyncCallback(async () => {
|
||||
await meetingSettingsService.openSavedRecordings();
|
||||
}, [meetingSettingsService]);
|
||||
|
||||
const handleRestartApp = useAsyncCallback(async () => {
|
||||
await desktopApiService.handler.ui.restartApp();
|
||||
}, [desktopApiService]);
|
||||
|
||||
return (
|
||||
<div className={styles.meetingWrapper}>
|
||||
<SettingHeader
|
||||
@@ -304,8 +303,8 @@ const MeetingsSettingsMain = () => {
|
||||
descriptionKey="com.affine.settings.meetings.privacy.screen-system-audio-recording.description"
|
||||
permissionSettingKey="com.affine.settings.meetings.privacy.screen-system-audio-recording.permission-setting"
|
||||
hasPermission={permissions?.screen || false}
|
||||
onOpenPermissionSetting={
|
||||
handleOpenScreenRecordingPermissionSetting
|
||||
onOpenPermissionSetting={() =>
|
||||
handleOpenPermissionSetting('screen')
|
||||
}
|
||||
/>
|
||||
<PermissionSettingRow
|
||||
@@ -313,11 +312,23 @@ const MeetingsSettingsMain = () => {
|
||||
descriptionKey="com.affine.settings.meetings.privacy.microphone.description"
|
||||
permissionSettingKey="com.affine.settings.meetings.privacy.microphone.permission-setting"
|
||||
hasPermission={permissions?.microphone || false}
|
||||
onOpenPermissionSetting={
|
||||
handleOpenMicrophoneRecordingPermissionSetting
|
||||
onOpenPermissionSetting={() =>
|
||||
handleOpenPermissionSetting('microphone')
|
||||
}
|
||||
/>
|
||||
</SettingWrapper>
|
||||
<SettingWrapper>
|
||||
<SettingRow
|
||||
name={t['com.affine.settings.meetings.privacy.issues']()}
|
||||
desc={t[
|
||||
'com.affine.settings.meetings.privacy.issues.description'
|
||||
]()}
|
||||
>
|
||||
<Button onClick={handleRestartApp}>
|
||||
{t['com.affine.settings.meetings.privacy.issues.restart']()}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -130,7 +130,7 @@ export class MeetingSettingsService extends Service {
|
||||
);
|
||||
}
|
||||
|
||||
async askForMeetingPermission(type: 'microphone') {
|
||||
async askForMeetingPermission(type: 'microphone' | 'screen') {
|
||||
return this.desktopApiService?.handler.recording.askForMeetingPermission(
|
||||
type
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user