This commit is contained in:
commit
b550f64a4b
7 changed files with 18 additions and 25 deletions
18
app/main.ts
18
app/main.ts
|
@ -1932,24 +1932,14 @@ ipc.on(
|
||||||
|
|
||||||
// Permissions Popup-related IPC calls
|
// Permissions Popup-related IPC calls
|
||||||
|
|
||||||
ipc.handle('show-permissions-popup', async () => {
|
|
||||||
try {
|
|
||||||
await showPermissionsPopupWindow(false, false);
|
|
||||||
} catch (error) {
|
|
||||||
getLogger().error(
|
|
||||||
'show-permissions-popup error:',
|
|
||||||
error && error.stack ? error.stack : error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ipc.handle(
|
ipc.handle(
|
||||||
'show-calling-permissions-popup',
|
'show-permissions-popup',
|
||||||
async (_event: Electron.Event, forCamera: boolean) => {
|
async (_event: Electron.Event, forCalling: boolean, forCamera: boolean) => {
|
||||||
try {
|
try {
|
||||||
await showPermissionsPopupWindow(true, forCamera);
|
await showPermissionsPopupWindow(forCalling, forCamera);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
getLogger().error(
|
getLogger().error(
|
||||||
'show-calling-permissions-popup error:',
|
'show-permissions-popup error:',
|
||||||
error && error.stack ? error.stack : error
|
error && error.stack ? error.stack : error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,9 +250,8 @@ try {
|
||||||
// Settings-related events
|
// Settings-related events
|
||||||
|
|
||||||
window.showSettings = () => ipc.send('show-settings');
|
window.showSettings = () => ipc.send('show-settings');
|
||||||
window.showPermissionsPopup = () => ipc.invoke('show-permissions-popup');
|
window.showPermissionsPopup = (forCalling, forCamera) =>
|
||||||
window.showCallingPermissionsPopup = forCamera =>
|
ipc.invoke('show-permissions-popup', forCalling, forCamera);
|
||||||
ipc.invoke('show-calling-permissions-popup', forCamera);
|
|
||||||
|
|
||||||
ipc.on('show-keyboard-shortcuts', () => {
|
ipc.on('show-keyboard-shortcuts', () => {
|
||||||
window.Events.showKeyboardShortcuts();
|
window.Events.showKeyboardShortcuts();
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class RecorderClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(): Promise<boolean> {
|
async start(): Promise<boolean> {
|
||||||
const hasMicrophonePermission = await requestMicrophonePermissions();
|
const hasMicrophonePermission = await requestMicrophonePermissions(false);
|
||||||
if (!hasMicrophonePermission) {
|
if (!hasMicrophonePermission) {
|
||||||
log.info(
|
log.info(
|
||||||
'Recorder/start: Microphone permission was denied, new audio recording not allowed.'
|
'Recorder/start: Microphone permission was denied, new audio recording not allowed.'
|
||||||
|
|
|
@ -1550,7 +1550,7 @@ export class CallingClass {
|
||||||
private async requestCameraPermissions(): Promise<boolean> {
|
private async requestCameraPermissions(): Promise<boolean> {
|
||||||
const cameraPermission = await window.getMediaCameraPermissions();
|
const cameraPermission = await window.getMediaCameraPermissions();
|
||||||
if (!cameraPermission) {
|
if (!cameraPermission) {
|
||||||
await window.showCallingPermissionsPopup(true);
|
await window.showPermissionsPopup(true, true);
|
||||||
|
|
||||||
// Check the setting again (from the source of truth).
|
// Check the setting again (from the source of truth).
|
||||||
return window.getMediaCameraPermissions();
|
return window.getMediaCameraPermissions();
|
||||||
|
@ -1560,7 +1560,7 @@ export class CallingClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async requestPermissions(isVideoCall: boolean): Promise<boolean> {
|
private async requestPermissions(isVideoCall: boolean): Promise<boolean> {
|
||||||
const microphonePermission = await requestMicrophonePermissions();
|
const microphonePermission = await requestMicrophonePermissions(true);
|
||||||
if (microphonePermission) {
|
if (microphonePermission) {
|
||||||
if (isVideoCall) {
|
if (isVideoCall) {
|
||||||
return this.requestCameraPermissions();
|
return this.requestCameraPermissions();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
export async function requestCameraPermissions(): Promise<boolean> {
|
export async function requestCameraPermissions(): Promise<boolean> {
|
||||||
if (!(await window.getMediaCameraPermissions())) {
|
if (!(await window.getMediaCameraPermissions())) {
|
||||||
await window.showCallingPermissionsPopup(true);
|
await window.showPermissionsPopup(true, true);
|
||||||
|
|
||||||
// Check the setting again (from the source of truth).
|
// Check the setting again (from the source of truth).
|
||||||
return window.getMediaCameraPermissions();
|
return window.getMediaCameraPermissions();
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
export async function requestMicrophonePermissions(): Promise<boolean> {
|
export async function requestMicrophonePermissions(
|
||||||
|
forCalling: boolean
|
||||||
|
): Promise<boolean> {
|
||||||
const microphonePermission = await window.getMediaPermissions();
|
const microphonePermission = await window.getMediaPermissions();
|
||||||
if (!microphonePermission) {
|
if (!microphonePermission) {
|
||||||
await window.showCallingPermissionsPopup(false);
|
await window.showPermissionsPopup(forCalling, false);
|
||||||
|
|
||||||
// Check the setting again (from the source of truth).
|
// Check the setting again (from the source of truth).
|
||||||
return window.getMediaPermissions();
|
return window.getMediaPermissions();
|
||||||
|
|
6
ts/window.d.ts
vendored
6
ts/window.d.ts
vendored
|
@ -148,7 +148,10 @@ declare global {
|
||||||
startApp: () => void;
|
startApp: () => void;
|
||||||
|
|
||||||
removeSetupMenuItems: () => unknown;
|
removeSetupMenuItems: () => unknown;
|
||||||
showPermissionsPopup: () => Promise<void>;
|
showPermissionsPopup: (
|
||||||
|
forCalling: boolean,
|
||||||
|
forCamera: boolean
|
||||||
|
) => Promise<void>;
|
||||||
|
|
||||||
FontFace: typeof FontFace;
|
FontFace: typeof FontFace;
|
||||||
_: typeof Underscore;
|
_: typeof Underscore;
|
||||||
|
@ -204,7 +207,6 @@ declare global {
|
||||||
getTitle: () => string;
|
getTitle: () => string;
|
||||||
waitForEmptyEventQueue: () => Promise<void>;
|
waitForEmptyEventQueue: () => Promise<void>;
|
||||||
getVersion: () => string;
|
getVersion: () => string;
|
||||||
showCallingPermissionsPopup: (forCamera: boolean) => Promise<void>;
|
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
isActive: () => boolean;
|
isActive: () => boolean;
|
||||||
isAfterVersion: (version: string, anotherVersion: string) => boolean;
|
isAfterVersion: (version: string, anotherVersion: string) => boolean;
|
||||||
|
|
Loading…
Add table
Reference in a new issue