2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-09-17 22:24:21 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2022-06-08 22:00:32 +00:00
|
|
|
import { contextBridge } from 'electron';
|
2021-09-17 22:24:21 +00:00
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
import { SignalContext } from '../context';
|
2021-09-17 22:24:21 +00:00
|
|
|
|
|
|
|
import { createSetting } from '../../util/preload';
|
|
|
|
import { PermissionsPopup } from '../../components/PermissionsPopup';
|
|
|
|
|
|
|
|
const mediaCameraPermissions = createSetting('mediaCameraPermissions', {
|
|
|
|
getter: false,
|
|
|
|
});
|
|
|
|
const mediaPermissions = createSetting('mediaPermissions', {
|
|
|
|
getter: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld(
|
|
|
|
'nativeThemeListener',
|
|
|
|
window.SignalContext.nativeThemeListener
|
|
|
|
);
|
|
|
|
|
2021-10-07 23:28:47 +00:00
|
|
|
contextBridge.exposeInMainWorld('SignalContext', {
|
|
|
|
...SignalContext,
|
2021-09-17 22:24:21 +00:00
|
|
|
renderWindow: () => {
|
2022-06-13 21:39:35 +00:00
|
|
|
const { forCalling, forCamera } = SignalContext.config;
|
2021-09-17 22:24:21 +00:00
|
|
|
|
|
|
|
let message;
|
|
|
|
if (forCalling) {
|
|
|
|
if (forCamera) {
|
2021-10-07 23:28:47 +00:00
|
|
|
message = SignalContext.i18n('videoCallingPermissionNeeded');
|
2021-09-17 22:24:21 +00:00
|
|
|
} else {
|
2021-10-07 23:28:47 +00:00
|
|
|
message = SignalContext.i18n('audioCallingPermissionNeeded');
|
2021-09-17 22:24:21 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-10-07 23:28:47 +00:00
|
|
|
message = SignalContext.i18n('audioPermissionNeeded');
|
2021-09-17 22:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onClose() {
|
2022-12-21 18:41:48 +00:00
|
|
|
void SignalContext.executeMenuRole('close');
|
2021-09-17 22:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
React.createElement(PermissionsPopup, {
|
2021-10-07 23:28:47 +00:00
|
|
|
i18n: SignalContext.i18n,
|
2021-09-17 22:24:21 +00:00
|
|
|
message,
|
|
|
|
onAccept: () => {
|
|
|
|
if (!forCamera) {
|
2022-12-21 18:41:48 +00:00
|
|
|
void mediaPermissions.setValue(true);
|
2021-09-17 22:24:21 +00:00
|
|
|
} else {
|
2022-12-21 18:41:48 +00:00
|
|
|
void mediaCameraPermissions.setValue(true);
|
2021-09-17 22:24:21 +00:00
|
|
|
}
|
|
|
|
onClose();
|
|
|
|
},
|
|
|
|
onClose,
|
|
|
|
}),
|
|
|
|
document.getElementById('app')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|