Eliminate remaining Electron 8 deprecations
* Change systemPreferences.isDarkMode() to nativeTheme.shouldUseDarkColors * Remove vibrancy parameter to BrowserWindow * Update curve25519-n; removes context-aware deprecation warning * Set app.allowRendererProcessReuse = true to remove warning * Move from deprecated setters to direct property set * Serialized sender certificates: Store less, store plain object * isMenuBarAutoHide -> autoHideMenuBar * UUID: Fix sealed sender indicator on message details screen * Data._cleanData: Remove function keys, handle null in array Also: - run _cleanData when saving attachment download jobs - remove job from jobs table when the send itself throws error * _cleanData: Don't dig into strings, booleans, or numbers * getPropsForMessageDetail: Make it clear what we're reducing Co-authored-by: Ken Powers <ken@signal.org>
This commit is contained in:
parent
841461934d
commit
8d6cba1b43
11 changed files with 108 additions and 107 deletions
|
@ -230,9 +230,11 @@
|
||||||
|
|
||||||
const unidentifiedLookup = (
|
const unidentifiedLookup = (
|
||||||
this.get('unidentifiedDeliveries') || []
|
this.get('unidentifiedDeliveries') || []
|
||||||
).reduce((accumulator, item) => {
|
).reduce((accumulator, uuidOrE164) => {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
accumulator[item] = true;
|
accumulator[
|
||||||
|
ConversationController.getConversationId(uuidOrE164)
|
||||||
|
] = true;
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}, Object.create(null));
|
}, Object.create(null));
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,22 @@ module.exports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// When IPC arguments are prepared for the cross-process send, they are JSON.stringified.
|
// When IPC arguments are prepared for the cross-process send, they are JSON.stringified.
|
||||||
// We can't send ArrayBuffers or BigNumbers (what we get from proto library for dates).
|
// We can't send ArrayBuffers or BigNumbers (what we get from proto library for dates),
|
||||||
function _cleanData(data) {
|
// We also cannot send objects with function-value keys, like what protobufjs gives us.
|
||||||
|
function _cleanData(data, path = 'root') {
|
||||||
|
if (data === null || data === undefined) {
|
||||||
|
window.log.warn(`_cleanData: null or undefined value at path ${path}`);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof data === 'string' ||
|
||||||
|
typeof data === 'number' ||
|
||||||
|
typeof data === 'boolean'
|
||||||
|
) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
const keys = Object.keys(data);
|
const keys = Object.keys(data);
|
||||||
for (let index = 0, max = keys.length; index < max; index += 1) {
|
for (let index = 0, max = keys.length; index < max; index += 1) {
|
||||||
const key = keys[index];
|
const key = keys[index];
|
||||||
|
@ -192,15 +206,21 @@ function _cleanData(data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFunction(value.toNumber)) {
|
if (isFunction(value)) {
|
||||||
|
// To prepare for Electron v9 IPC, we need to take functions off of any object
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
delete data[key];
|
||||||
|
} else if (isFunction(value.toNumber)) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
data[key] = value.toNumber();
|
data[key] = value.toNumber();
|
||||||
} else if (Array.isArray(value)) {
|
} else if (Array.isArray(value)) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
data[key] = value.map(item => _cleanData(item));
|
data[key] = value.map((item, mapIndex) =>
|
||||||
|
_cleanData(item, `${path}.${key}.${mapIndex}`)
|
||||||
|
);
|
||||||
} else if (isObject(value)) {
|
} else if (isObject(value)) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
data[key] = _cleanData(value);
|
data[key] = _cleanData(value, `${path}.${key}`);
|
||||||
} else if (
|
} else if (
|
||||||
typeof value !== 'string' &&
|
typeof value !== 'string' &&
|
||||||
typeof value !== 'number' &&
|
typeof value !== 'number' &&
|
||||||
|
@ -209,6 +229,7 @@ function _cleanData(data) {
|
||||||
window.log.info(`_cleanData: key ${key} had type ${typeof value}`);
|
window.log.info(`_cleanData: key ${key} had type ${typeof value}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,19 +373,25 @@ function makeChannel(fnName) {
|
||||||
const jobId = _makeJob(fnName);
|
const jobId = _makeJob(fnName);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send(SQL_CHANNEL_KEY, jobId, fnName, ...args);
|
try {
|
||||||
|
ipcRenderer.send(SQL_CHANNEL_KEY, jobId, fnName, ...args);
|
||||||
|
|
||||||
_updateJob(jobId, {
|
_updateJob(jobId, {
|
||||||
resolve,
|
resolve,
|
||||||
reject,
|
reject,
|
||||||
args: _DEBUG ? args : null,
|
args: _DEBUG ? args : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() =>
|
() =>
|
||||||
reject(new Error(`SQL channel job ${jobId} (${fnName}) timed out`)),
|
reject(new Error(`SQL channel job ${jobId} (${fnName}) timed out`)),
|
||||||
DATABASE_UPDATE_TIMEOUT
|
DATABASE_UPDATE_TIMEOUT
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
_removeJob(jobId);
|
||||||
|
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -515,16 +542,8 @@ async function removeAllSignedPreKeys() {
|
||||||
|
|
||||||
const ITEM_KEYS = {
|
const ITEM_KEYS = {
|
||||||
identityKey: ['value.pubKey', 'value.privKey'],
|
identityKey: ['value.pubKey', 'value.privKey'],
|
||||||
senderCertificate: [
|
senderCertificate: ['value.serialized'],
|
||||||
'value.certificate',
|
senderCertificateWithUuid: ['value.serialized'],
|
||||||
'value.signature',
|
|
||||||
'value.serialized',
|
|
||||||
],
|
|
||||||
senderCertificateWithUuid: [
|
|
||||||
'value.certificate',
|
|
||||||
'value.signature',
|
|
||||||
'value.serialized',
|
|
||||||
],
|
|
||||||
signaling_key: ['value'],
|
signaling_key: ['value'],
|
||||||
profileKey: ['value'],
|
profileKey: ['value'],
|
||||||
};
|
};
|
||||||
|
@ -981,7 +1000,7 @@ async function getNextAttachmentDownloadJobs(limit) {
|
||||||
return channels.getNextAttachmentDownloadJobs(limit);
|
return channels.getNextAttachmentDownloadJobs(limit);
|
||||||
}
|
}
|
||||||
async function saveAttachmentDownloadJob(job) {
|
async function saveAttachmentDownloadJob(job) {
|
||||||
await channels.saveAttachmentDownloadJob(job);
|
await channels.saveAttachmentDownloadJob(_cleanData(job));
|
||||||
}
|
}
|
||||||
async function setAttachmentDownloadJobPending(id, pending) {
|
async function setAttachmentDownloadJobPending(id, pending) {
|
||||||
await channels.setAttachmentDownloadJobPending(id, pending);
|
await channels.setAttachmentDownloadJobPending(id, pending);
|
||||||
|
|
|
@ -43,28 +43,27 @@ function initialize({ events, storage, navigator, logger }) {
|
||||||
function scheduleNextRotation() {
|
function scheduleNextRotation() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const certificate = storage.get('senderCertificate');
|
const certificate = storage.get('senderCertificate');
|
||||||
if (!certificate) {
|
if (!certificate || !certificate.expires) {
|
||||||
setTimeoutForNextRun(scheduledTime || now);
|
setTimeoutForNextRun(scheduledTime || now);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The useful information in a SenderCertificate is all serialized, so we
|
|
||||||
// need to do another layer of decoding.
|
|
||||||
const decoded = textsecure.protobuf.SenderCertificate.Certificate.decode(
|
|
||||||
certificate.certificate
|
|
||||||
);
|
|
||||||
const expires = decoded.expires.toNumber();
|
|
||||||
|
|
||||||
// If we have a time in place and it's already before the safety zone before expire,
|
// If we have a time in place and it's already before the safety zone before expire,
|
||||||
// we keep it
|
// we keep it
|
||||||
if (scheduledTime && scheduledTime <= expires - MINIMUM_TIME_LEFT) {
|
if (
|
||||||
|
scheduledTime &&
|
||||||
|
scheduledTime <= certificate.expires - MINIMUM_TIME_LEFT
|
||||||
|
) {
|
||||||
setTimeoutForNextRun(scheduledTime);
|
setTimeoutForNextRun(scheduledTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we reset every day, or earlier if the safety zone requires it
|
// Otherwise, we reset every day, or earlier if the safety zone requires it
|
||||||
const time = Math.min(now + ONE_DAY, expires - MINIMUM_TIME_LEFT);
|
const time = Math.min(
|
||||||
|
now + ONE_DAY,
|
||||||
|
certificate.expires - MINIMUM_TIME_LEFT
|
||||||
|
);
|
||||||
setTimeoutForNextRun(time);
|
setTimeoutForNextRun(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,18 +87,21 @@ function initialize({ events, storage, navigator, logger }) {
|
||||||
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(
|
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(
|
||||||
certificate
|
certificate
|
||||||
);
|
);
|
||||||
const decoded = textsecure.protobuf.SenderCertificate.decode(
|
const decodedContainer = textsecure.protobuf.SenderCertificate.decode(
|
||||||
arrayBuffer
|
arrayBuffer
|
||||||
);
|
);
|
||||||
|
const decodedCert = textsecure.protobuf.SenderCertificate.Certificate.decode(
|
||||||
decoded.certificate = decoded.certificate.toArrayBuffer();
|
decodedContainer.certificate
|
||||||
decoded.signature = decoded.signature.toArrayBuffer();
|
|
||||||
decoded.serialized = arrayBuffer;
|
|
||||||
|
|
||||||
storage.put(
|
|
||||||
`senderCertificate${withUuid ? 'WithUuid' : ''}`,
|
|
||||||
decoded
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// We don't want to send a protobuf-generated object across IPC, so we make
|
||||||
|
// our own object.
|
||||||
|
const toSave = {
|
||||||
|
expires: decodedCert.expires.toNumber(),
|
||||||
|
serialized: arrayBuffer,
|
||||||
|
};
|
||||||
|
|
||||||
|
storage.put(`senderCertificate${withUuid ? 'WithUuid' : ''}`, toSave);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
15
main.js
15
main.js
|
@ -41,6 +41,10 @@ console.log('Set Windows Application User Model ID (AUMID)', {
|
||||||
});
|
});
|
||||||
app.setAppUserModelId(appUserModelId);
|
app.setAppUserModelId(appUserModelId);
|
||||||
|
|
||||||
|
// We don't navigate, but this is the way of the future
|
||||||
|
// https://github.com/electron/electron/issues/18397
|
||||||
|
app.allowRendererProcessReuse = true;
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
@ -250,7 +254,6 @@ function createWindow() {
|
||||||
config.environment === 'test' || config.environment === 'test-lib'
|
config.environment === 'test' || config.environment === 'test-lib'
|
||||||
? '#ffffff' // Tests should always be rendered on a white background
|
? '#ffffff' // Tests should always be rendered on a white background
|
||||||
: '#3a76f0',
|
: '#3a76f0',
|
||||||
vibrancy: 'appearance-based',
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
|
@ -311,7 +314,7 @@ function createWindow() {
|
||||||
// so if we need to recreate the window, we have the most recent settings
|
// so if we need to recreate the window, we have the most recent settings
|
||||||
windowConfig = {
|
windowConfig = {
|
||||||
maximized: mainWindow.isMaximized(),
|
maximized: mainWindow.isMaximized(),
|
||||||
autoHideMenuBar: mainWindow.isMenuBarAutoHide(),
|
autoHideMenuBar: mainWindow.autoHideMenuBar,
|
||||||
fullscreen: mainWindow.isFullScreen(),
|
fullscreen: mainWindow.isFullScreen(),
|
||||||
width: size[0],
|
width: size[0],
|
||||||
height: size[1],
|
height: size[1],
|
||||||
|
@ -496,7 +499,6 @@ function showAbout() {
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
backgroundColor: '#3a76f0',
|
backgroundColor: '#3a76f0',
|
||||||
show: false,
|
show: false,
|
||||||
vibrancy: 'appearance-based',
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
|
@ -545,7 +547,6 @@ async function showSettingsWindow() {
|
||||||
backgroundColor: '#3a76f0',
|
backgroundColor: '#3a76f0',
|
||||||
show: false,
|
show: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
vibrancy: 'appearance-based',
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
|
@ -665,7 +666,6 @@ async function showDebugLogWindow() {
|
||||||
backgroundColor: '#3a76f0',
|
backgroundColor: '#3a76f0',
|
||||||
show: false,
|
show: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
vibrancy: 'appearance-based',
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
|
@ -714,7 +714,6 @@ async function showPermissionsPopupWindow() {
|
||||||
backgroundColor: '#3a76f0',
|
backgroundColor: '#3a76f0',
|
||||||
show: false,
|
show: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
vibrancy: 'appearance-based',
|
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
|
@ -990,7 +989,7 @@ app.on('will-finish-launching', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.on('set-badge-count', (event, count) => {
|
ipc.on('set-badge-count', (event, count) => {
|
||||||
app.setBadgeCount(count);
|
app.badgeCount = count;
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.on('remove-setup-menu-items', () => {
|
ipc.on('remove-setup-menu-items', () => {
|
||||||
|
@ -1023,7 +1022,7 @@ ipc.on('restart', () => {
|
||||||
|
|
||||||
ipc.on('set-auto-hide-menu-bar', (event, autoHide) => {
|
ipc.on('set-auto-hide-menu-bar', (event, autoHide) => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.setAutoHideMenuBar(autoHide);
|
mainWindow.autoHideMenuBar = autoHide;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
"classnames": "2.2.5",
|
"classnames": "2.2.5",
|
||||||
"config": "1.28.1",
|
"config": "1.28.1",
|
||||||
"copy-text-to-clipboard": "2.1.0",
|
"copy-text-to-clipboard": "2.1.0",
|
||||||
"curve25519-n": "https://github.com/scottnonnenberg-signal/node-curve25519.git#1bd0580843dcf836284dee7f1c4dfb4c698f7969",
|
"curve25519-n": "https://github.com/scottnonnenberg-signal/node-curve25519.git#3e94f60bc54b2426476520d8d1a0aa835c25f5cc",
|
||||||
"draft-js": "0.10.5",
|
"draft-js": "0.10.5",
|
||||||
"electron-context-menu": "0.11.0",
|
"electron-context-menu": "0.11.0",
|
||||||
"electron-editor-context-menu": "1.1.1",
|
"electron-editor-context-menu": "1.1.1",
|
||||||
|
|
|
@ -5,7 +5,7 @@ const url = require('url');
|
||||||
const i18n = require('./js/modules/i18n');
|
const i18n = require('./js/modules/i18n');
|
||||||
const { makeGetter, makeSetter } = require('./preload_utils');
|
const { makeGetter, makeSetter } = require('./preload_utils');
|
||||||
|
|
||||||
const { systemPreferences } = remote.require('electron');
|
const { nativeTheme } = remote.require('electron');
|
||||||
|
|
||||||
const config = url.parse(window.location.toString(), true).query;
|
const config = url.parse(window.location.toString(), true).query;
|
||||||
const { locale } = config;
|
const { locale } = config;
|
||||||
|
@ -17,22 +17,16 @@ window.theme = config.theme;
|
||||||
window.i18n = i18n.setup(locale, localeMessages);
|
window.i18n = i18n.setup(locale, localeMessages);
|
||||||
|
|
||||||
function setSystemTheme() {
|
function setSystemTheme() {
|
||||||
window.systemTheme = systemPreferences.isDarkMode() ? 'dark' : 'light';
|
window.systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
|
|
||||||
setSystemTheme();
|
setSystemTheme();
|
||||||
|
|
||||||
window.subscribeToSystemThemeChange = fn => {
|
window.subscribeToSystemThemeChange = fn => {
|
||||||
if (!systemPreferences.subscribeNotification) {
|
nativeTheme.on('updated', () => {
|
||||||
return;
|
setSystemTheme();
|
||||||
}
|
fn();
|
||||||
systemPreferences.subscribeNotification(
|
});
|
||||||
'AppleInterfaceThemeChangedNotification',
|
|
||||||
() => {
|
|
||||||
setSystemTheme();
|
|
||||||
fn();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
require('./js/logging');
|
require('./js/logging');
|
||||||
|
|
18
preload.js
18
preload.js
|
@ -13,7 +13,7 @@ try {
|
||||||
|
|
||||||
const { remote } = electron;
|
const { remote } = electron;
|
||||||
const { app } = remote;
|
const { app } = remote;
|
||||||
const { systemPreferences } = remote.require('electron');
|
const { nativeTheme } = remote.require('electron');
|
||||||
|
|
||||||
window.PROTO_ROOT = 'protos';
|
window.PROTO_ROOT = 'protos';
|
||||||
const config = require('url').parse(window.location.toString(), true).query;
|
const config = require('url').parse(window.location.toString(), true).query;
|
||||||
|
@ -38,22 +38,16 @@ try {
|
||||||
window.isBehindProxy = () => Boolean(config.proxyUrl);
|
window.isBehindProxy = () => Boolean(config.proxyUrl);
|
||||||
|
|
||||||
function setSystemTheme() {
|
function setSystemTheme() {
|
||||||
window.systemTheme = systemPreferences.isDarkMode() ? 'dark' : 'light';
|
window.systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
|
|
||||||
setSystemTheme();
|
setSystemTheme();
|
||||||
|
|
||||||
window.subscribeToSystemThemeChange = fn => {
|
window.subscribeToSystemThemeChange = fn => {
|
||||||
if (!systemPreferences.subscribeNotification) {
|
nativeTheme.on('updated', () => {
|
||||||
return;
|
setSystemTheme();
|
||||||
}
|
fn();
|
||||||
systemPreferences.subscribeNotification(
|
});
|
||||||
'AppleInterfaceThemeChangedNotification',
|
|
||||||
() => {
|
|
||||||
setSystemTheme();
|
|
||||||
fn();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.isBeforeVersion = (toCheck, baseVersion) => {
|
window.isBeforeVersion = (toCheck, baseVersion) => {
|
||||||
|
|
|
@ -9,29 +9,23 @@ const config = url.parse(window.location.toString(), true).query;
|
||||||
const { locale } = config;
|
const { locale } = config;
|
||||||
const localeMessages = ipcRenderer.sendSync('locale-data');
|
const localeMessages = ipcRenderer.sendSync('locale-data');
|
||||||
|
|
||||||
const { systemPreferences } = remote.require('electron');
|
const { nativeTheme } = remote.require('electron');
|
||||||
|
|
||||||
window.platform = process.platform;
|
window.platform = process.platform;
|
||||||
window.theme = config.theme;
|
window.theme = config.theme;
|
||||||
window.i18n = i18n.setup(locale, localeMessages);
|
window.i18n = i18n.setup(locale, localeMessages);
|
||||||
|
|
||||||
function setSystemTheme() {
|
function setSystemTheme() {
|
||||||
window.systemTheme = systemPreferences.isDarkMode() ? 'dark' : 'light';
|
window.systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
|
|
||||||
setSystemTheme();
|
setSystemTheme();
|
||||||
|
|
||||||
window.subscribeToSystemThemeChange = fn => {
|
window.subscribeToSystemThemeChange = fn => {
|
||||||
if (!systemPreferences.subscribeNotification) {
|
nativeTheme.on('updated', () => {
|
||||||
return;
|
setSystemTheme();
|
||||||
}
|
fn();
|
||||||
systemPreferences.subscribeNotification(
|
});
|
||||||
'AppleInterfaceThemeChangedNotification',
|
|
||||||
() => {
|
|
||||||
setSystemTheme();
|
|
||||||
fn();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.getEnvironment = () => config.environment;
|
window.getEnvironment = () => config.environment;
|
||||||
|
|
|
@ -10,7 +10,7 @@ const { deriveStickerPackKey } = require('../js/modules/crypto');
|
||||||
const { makeGetter } = require('../preload_utils');
|
const { makeGetter } = require('../preload_utils');
|
||||||
|
|
||||||
const { dialog } = remote;
|
const { dialog } = remote;
|
||||||
const { systemPreferences } = remote.require('electron');
|
const { nativeTheme } = remote.require('electron');
|
||||||
|
|
||||||
window.ROOT_PATH = window.location.href.startsWith('file') ? '../../' : '/';
|
window.ROOT_PATH = window.location.href.startsWith('file') ? '../../' : '/';
|
||||||
window.PROTO_ROOT = '../../protos';
|
window.PROTO_ROOT = '../../protos';
|
||||||
|
@ -157,7 +157,7 @@ const getThemeSetting = makeGetter('theme-setting');
|
||||||
async function resolveTheme() {
|
async function resolveTheme() {
|
||||||
const theme = (await getThemeSetting()) || 'light';
|
const theme = (await getThemeSetting()) || 'light';
|
||||||
if (process.platform === 'darwin' && theme === 'system') {
|
if (process.platform === 'darwin' && theme === 'system') {
|
||||||
return systemPreferences.isDarkMode() ? 'dark' : 'light';
|
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
@ -170,11 +170,8 @@ async function applyTheme() {
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', applyTheme);
|
window.addEventListener('DOMContentLoaded', applyTheme);
|
||||||
|
|
||||||
if (systemPreferences && systemPreferences.subscribeNotification) {
|
nativeTheme.on('updated', () => {
|
||||||
systemPreferences.subscribeNotification(
|
applyTheme();
|
||||||
'AppleInterfaceThemeChangedNotification',
|
});
|
||||||
applyTheme
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.log.info('sticker-creator preload complete...');
|
window.log.info('sticker-creator preload complete...');
|
||||||
|
|
|
@ -170,7 +170,7 @@ describe('SecretSessionCipher', () => {
|
||||||
|
|
||||||
const ciphertext = await aliceCipher.encrypt(
|
const ciphertext = await aliceCipher.encrypt(
|
||||||
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
||||||
senderCertificate,
|
{ serialized: senderCertificate.serialized },
|
||||||
bytesFromString('smert za smert')
|
bytesFromString('smert za smert')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ describe('SecretSessionCipher', () => {
|
||||||
|
|
||||||
const ciphertext = await aliceCipher.encrypt(
|
const ciphertext = await aliceCipher.encrypt(
|
||||||
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
||||||
senderCertificate,
|
{ serialized: senderCertificate.serialized },
|
||||||
bytesFromString('и вот я')
|
bytesFromString('и вот я')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ describe('SecretSessionCipher', () => {
|
||||||
|
|
||||||
const ciphertext = await aliceCipher.encrypt(
|
const ciphertext = await aliceCipher.encrypt(
|
||||||
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
||||||
senderCertificate,
|
{ serialized: senderCertificate.serialized },
|
||||||
bytesFromString('и вот я')
|
bytesFromString('и вот я')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ describe('SecretSessionCipher', () => {
|
||||||
|
|
||||||
const ciphertext = await aliceCipher.encrypt(
|
const ciphertext = await aliceCipher.encrypt(
|
||||||
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
new libsignal.SignalProtocolAddress('+14152222222', 1),
|
||||||
senderCertificate,
|
{ serialized: senderCertificate.serialized },
|
||||||
bytesFromString('smert za smert')
|
bytesFromString('smert za smert')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -5543,9 +5543,9 @@ currently-unhandled@^0.4.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
array-find-index "^1.0.1"
|
array-find-index "^1.0.1"
|
||||||
|
|
||||||
"curve25519-n@https://github.com/scottnonnenberg-signal/node-curve25519.git#1bd0580843dcf836284dee7f1c4dfb4c698f7969":
|
"curve25519-n@https://github.com/scottnonnenberg-signal/node-curve25519.git#3e94f60bc54b2426476520d8d1a0aa835c25f5cc":
|
||||||
version "1.5.0"
|
version "1.5.0"
|
||||||
resolved "https://github.com/scottnonnenberg-signal/node-curve25519.git#1bd0580843dcf836284dee7f1c4dfb4c698f7969"
|
resolved "https://github.com/scottnonnenberg-signal/node-curve25519.git#3e94f60bc54b2426476520d8d1a0aa835c25f5cc"
|
||||||
dependencies:
|
dependencies:
|
||||||
bindings "^1.5.0"
|
bindings "^1.5.0"
|
||||||
nan "^2.14.0"
|
nan "^2.14.0"
|
||||||
|
|
Loading…
Reference in a new issue