2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2018-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
/* global $, Whisper */
|
|
|
|
|
2019-11-07 21:36:16 +00:00
|
|
|
$(document).on('keydown', e => {
|
2018-07-03 22:33:50 +00:00
|
|
|
if (e.keyCode === 27) {
|
|
|
|
window.closeSettings();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
const getInitialData = async () => ({
|
|
|
|
deviceName: await window.getDeviceName(),
|
|
|
|
|
|
|
|
themeSetting: await window.getThemeSetting(),
|
|
|
|
hideMenuBar: await window.getHideMenuBar(),
|
|
|
|
|
|
|
|
notificationSetting: await window.getNotificationSetting(),
|
|
|
|
audioNotification: await window.getAudioNotification(),
|
2020-08-24 21:45:31 +00:00
|
|
|
notificationDrawAttention: await window.getNotificationDrawAttention(),
|
2020-09-14 22:16:57 +00:00
|
|
|
countMutedConversations: await window.getCountMutedConversations(),
|
2018-07-03 22:33:50 +00:00
|
|
|
|
2018-07-19 01:46:12 +00:00
|
|
|
spellCheck: await window.getSpellCheck(),
|
|
|
|
|
2020-06-04 18:16:19 +00:00
|
|
|
incomingCallNotification: await window.getIncomingCallNotification(),
|
|
|
|
callRingtoneNotification: await window.getCallRingtoneNotification(),
|
|
|
|
callSystemNotification: await window.getCallSystemNotification(),
|
|
|
|
alwaysRelayCalls: await window.getAlwaysRelayCalls(),
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
mediaPermissions: await window.getMediaPermissions(),
|
2020-06-04 18:16:19 +00:00
|
|
|
mediaCameraPermissions: await window.getMediaCameraPermissions(),
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
isPrimary: await window.isPrimary(),
|
|
|
|
lastSyncTime: await window.getLastSyncTime(),
|
|
|
|
});
|
|
|
|
|
|
|
|
window.initialRequest = getInitialData();
|
2018-07-07 00:48:14 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line more/no-then
|
2019-01-16 03:03:56 +00:00
|
|
|
window.initialRequest.then(
|
|
|
|
data => {
|
|
|
|
window.initialData = data;
|
|
|
|
window.view = new Whisper.SettingsView();
|
|
|
|
window.view.$el.appendTo($body);
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
window.log.error(
|
|
|
|
'settings.initialRequest error:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
window.closeSettings();
|
|
|
|
}
|
|
|
|
);
|