2021-10-27 16:16:09 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-11-05 08:47:32 +00:00
|
|
|
export async function requestMicrophonePermissions(
|
|
|
|
forCalling: boolean
|
|
|
|
): Promise<boolean> {
|
2023-01-13 00:24:59 +00:00
|
|
|
const microphonePermission = await window.IPC.getMediaPermissions();
|
2021-10-27 16:16:09 +00:00
|
|
|
if (!microphonePermission) {
|
2023-01-13 00:24:59 +00:00
|
|
|
await window.IPC.showPermissionsPopup(forCalling, false);
|
2021-10-27 16:16:09 +00:00
|
|
|
|
|
|
|
// Check the setting again (from the source of truth).
|
2023-01-13 00:24:59 +00:00
|
|
|
return window.IPC.getMediaPermissions();
|
2021-10-27 16:16:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|