Make getMediaPermissions synchronous

pull/965/head
Mikunj 5 years ago
parent eeb6257526
commit 6767f71a6b

@ -1073,13 +1073,10 @@ function removeDarkOverlay() {
}
}
// This one is different because its single source of truth is userConfig, not IndexedDB
// This should be called with an ipc sendSync
ipc.on('get-media-permissions', event => {
event.sender.send(
'get-success-media-permissions',
null,
userConfig.get('mediaPermissions') || false
);
// eslint-disable-next-line no-param-reassign
event.returnValue = userConfig.get('mediaPermissions') || false;
});
ipc.on('set-media-permissions', (event, value) => {
userConfig.set('mediaPermissions', value);

@ -212,13 +212,7 @@ window.getSettingValue = (settingID, comparisonValue = null) => {
// returns 'false' when the value is 'dark'.
if (settingID === 'media-permissions') {
let permissionValue;
// eslint-disable-next-line more/no-then
window.getMediaPermissions().then(value => {
permissionValue = value;
});
return permissionValue;
return window.getMediaPermissions();
}
const settingVal = window.storage.get(settingID);
@ -236,17 +230,7 @@ window.setSettingValue = (settingID, value) => {
// Get the message TTL setting
window.getMessageTTL = () => window.storage.get('message-ttl', 24);
window.getMediaPermissions = () =>
new Promise((resolve, reject) => {
ipc.once('get-success-media-permissions', (_event, error, value) => {
if (error) {
return reject(error);
}
return resolve(value);
});
ipc.send('get-media-permissions');
});
window.getMediaPermissions = () => ipc.sendSync('get-media-permissions')
window.addSetupMenuItems = () => ipc.send('add-setup-menu-items');
window.removeSetupMenuItems = () => ipc.send('remove-setup-menu-items');

Loading…
Cancel
Save