signal-desktop/js/permissions_popup_start.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

/* global $, Whisper, i18n */
2019-11-07 21:36:16 +00:00
$(document).on('keydown', e => {
if (e.keyCode === 27) {
window.closePermissionsPopup();
}
});
const $body = $(document.body);
2019-05-16 22:32:38 +00:00
async function applyTheme() {
const theme = await window.getThemeSetting();
$body.removeClass('light-theme');
$body.removeClass('dark-theme');
$body.addClass(`${theme === 'system' ? window.systemTheme : theme}-theme`);
}
applyTheme();
window.subscribeToSystemThemeChange(() => {
applyTheme();
});
2020-06-04 18:16:19 +00:00
let message;
if (window.forCalling) {
if (window.forCamera) {
message = i18n('videoCallingPermissionNeeded');
} else {
message = i18n('audioCallingPermissionNeeded');
}
} else {
message = i18n('audioPermissionNeeded');
}
window.view = new Whisper.ConfirmationDialogView({
2020-06-04 18:16:19 +00:00
message,
okText: i18n('allowAccess'),
resolve: () => {
2020-06-04 18:16:19 +00:00
if (!window.forCamera) {
window.setMediaPermissions(true);
} else {
window.setMediaCameraPermissions(true);
}
window.closePermissionsPopup();
},
reject: window.closePermissionsPopup,
});
window.view.$el.appendTo($body);