Skip to content

Commit

Permalink
Update to Electron 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Mar 13, 2019
1 parent 667b2e6 commit ae161c6
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 57 deletions.
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@
"message": "Quit",
"description": "Command in the tray icon menu, to quit the application"
},
"trayTooltip": {
"signalDesktop": {
"message": "Signal Desktop",
"description": "Tooltip for the tray icon"
},
Expand Down
1 change: 1 addition & 0 deletions app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ function updateForMac(template, messages, options) {

// Add the OSX-specific Signal Desktop menu at the far left
template.unshift({
label: messages.signalDesktop.message,
submenu: [
{
label: messages.aboutSignalDesktop.message,
Expand Down
2 changes: 1 addition & 1 deletion app/tray_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function createTrayIcon(getMainWindow, messages) {

tray.on('click', tray.showWindow);

tray.setToolTip(messages.trayTooltip.message);
tray.setToolTip(messages.signalDesktop.message);
tray.updateContextMenu();

return tray;
Expand Down
5 changes: 2 additions & 3 deletions js/modules/link_previews.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { isNumber, compact } = require('lodash');
const he = require('he');
const punycode = require('punycode');
const nodeUrl = require('url');
const LinkifyIt = require('linkify-it');

const linkify = LinkifyIt();
Expand Down Expand Up @@ -330,8 +330,7 @@ function isLinkSneaky(link) {
const domain = getDomain(link);

// This is necesary because getDomain returns domains in punycode form
// We'd like to use require('url').domainToUnicode() but it's a no-op in a BrowserWindow
const unicodeDomain = punycode.toUnicode(domain);
const unicodeDomain = nodeUrl.domainToUnicode(domain);

const chunks = unicodeDomain.split('.');
for (let i = 0, max = chunks.length; i < max; i += 1) {
Expand Down
37 changes: 19 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,22 @@ function showWindow() {

if (!process.mas) {
console.log('making app single instance');
const shouldQuit = app.makeSingleInstance(() => {
// Someone tried to run a second instance, we should focus our window
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}

showWindow();
}
return true;
});

if (shouldQuit) {
const gotLock = app.requestSingleInstanceLock();
if (!gotLock) {
console.log('quitting; we are the second instance');
app.exit();
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}

showWindow();
}
return true;
});
}
}

Expand Down Expand Up @@ -217,7 +218,7 @@ function createWindow() {
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
// sandbox: true,
contextIsolation: false,
preload: path.join(__dirname, 'preload.js'),
nativeWindowOpen: true,
},
Expand Down Expand Up @@ -444,8 +445,8 @@ function showAbout() {
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'about_preload.js'),
// sandbox: true,
nativeWindowOpen: true,
},
parent: mainWindow,
Expand Down Expand Up @@ -490,8 +491,8 @@ async function showSettingsWindow() {
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'settings_preload.js'),
// sandbox: true,
nativeWindowOpen: true,
},
parent: mainWindow,
Expand Down Expand Up @@ -535,8 +536,8 @@ async function showDebugLogWindow() {
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'debug_log_preload.js'),
// sandbox: true,
nativeWindowOpen: true,
},
parent: mainWindow,
Expand Down Expand Up @@ -583,8 +584,8 @@ async function showPermissionsPopupWindow() {
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(__dirname, 'permissions_popup_preload.js'),
// sandbox: true,
nativeWindowOpen: true,
},
parent: mainWindow,
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"pify": "3.0.0",
"protobufjs": "~6.8.6",
"proxy-agent": "3.0.3",
"punycode": "2.1.1",
"react": "16.2.0",
"react-contextmenu": "2.9.2",
"react-dom": "16.2.0",
Expand Down Expand Up @@ -113,7 +112,7 @@
"asar": "0.14.0",
"bower": "1.8.2",
"chai": "4.1.2",
"electron": "3.0.14",
"electron": "4.0.5",
"electron-builder": "20.13.5",
"electron-icon-maker": "0.0.3",
"eslint": "4.14.0",
Expand Down
1 change: 1 addition & 0 deletions test/app/fixtures/menu-mac-os-setup.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
{
"label": "Signal Desktop",
"submenu": [
{
"label": "About Signal Desktop",
Expand Down
1 change: 1 addition & 0 deletions test/app/fixtures/menu-mac-os.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
{
"label": "Signal Desktop",
"submenu": [
{
"label": "About Signal Desktop",
Expand Down
54 changes: 35 additions & 19 deletions ts/util/lint/exceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2386,49 +2386,65 @@
"rule": "eval",
"path": "node_modules/electron/electron.d.ts",
"line": " eval(code: string): void;",
"lineNumber": 1834,
"lineNumber": 2031,
"reasonCategory": "falseMatch",
"updated": "2018-09-15T00:38:04.183Z"
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-append(",
"path": "node_modules/electron/electron.d.ts",
"line": " append(menuItem: MenuItem): void;",
"lineNumber": 3232,
"lineNumber": 3431,
"reasonCategory": "falseMatch",
"updated": "2018-09-19T18:13:29.628Z"
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts",
"path": "node_modules/electron/node_modules/@types/node/globals.d.ts",
"line": " wrap(oldStream: ReadableStream): this;",
"lineNumber": 437,
"lineNumber": 573,
"reasonCategory": "falseMatch",
"updated": "2018-09-20T21:02:15.849Z"
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts",
"path": "node_modules/electron/node_modules/@types/node/globals.d.ts",
"line": " static wrap(code: string): string;",
"lineNumber": 792,
"lineNumber": 976,
"reasonCategory": "falseMatch",
"updated": "2018-09-20T20:45:24.002Z"
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-append(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts",
"line": " append(name: string, value: string): void;",
"lineNumber": 2355,
"rule": "eval",
"path": "node_modules/electron/node_modules/@types/node/repl.d.ts",
"line": " * Default: an async wrapper for the JavaScript `eval()` function. An `eval` function can",
"lineNumber": 31,
"reasonCategory": "falseMatch",
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "eval",
"path": "node_modules/electron/node_modules/@types/node/repl.d.ts",
"line": " * for the JavaScript `eval()` function.",
"lineNumber": 180,
"reasonCategory": "falseMatch",
"updated": "2018-09-20T21:02:15.849Z"
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-wrap(",
"path": "node_modules/electron/node_modules/@types/node/index.d.ts",
"path": "node_modules/electron/node_modules/@types/node/stream.d.ts",
"line": " wrap(oldStream: NodeJS.ReadableStream): this;",
"lineNumber": 5277,
"lineNumber": 32,
"reasonCategory": "falseMatch",
"updated": "2018-09-20T20:45:24.002Z"
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-append(",
"path": "node_modules/electron/node_modules/@types/node/url.d.ts",
"line": " append(name: string, value: string): void;",
"lineNumber": 90,
"reasonCategory": "falseMatch",
"updated": "2019-02-22T01:08:09.603Z"
},
{
"rule": "jQuery-$(",
Expand Down Expand Up @@ -6040,4 +6056,4 @@
"updated": "2018-09-17T20:50:40.689Z",
"reasonDetail": "Hard-coded value"
}
]
]
22 changes: 9 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@
version "10.10.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.10.1.tgz#d5c96ca246a418404914d180b7fdd625ad18eca6"

"@types/node@^8.0.24":
version "8.9.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.9.4.tgz#dfd327582a06c114eb6e0441fa3d6fab35edad48"
"@types/node@^10.12.18":
version "10.12.26"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.26.tgz#2dec19f1f7981c95cb54bab8f618ecb5dc983d0e"
integrity sha512-nMRqS+mL1TOnIJrL6LKJcNZPB8V3eTfRo9FQA2b5gDvrHurC8XbSA86KNe0dShlEL7ReWJv/OU9NL7Z0dnqWTg==

"@types/qs@6.5.1":
version "6.5.1"
Expand Down Expand Up @@ -2517,12 +2518,12 @@ electron-updater@2.21.10:
semver "^5.5.0"
source-map-support "^0.5.5"

electron@3.0.14:
version "3.0.14"
resolved "https://registry.yarnpkg.com/electron/-/electron-3.0.14.tgz#d54c51de3651c0fe48a6a6e9aef1ca98e5ea5796"
integrity sha512-1fG9bE0LzL5QXeEq2MC0dHdVO0pbZOnNlVAIyOyJaCFAu/TjLhxQfWj38bFUEojzuVlaR87tZz0iy2qlVZj3sw==
electron@4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/electron/-/electron-4.0.5.tgz#d8e7d8a581a3e31071b2226129b26b6110c1d877"
integrity sha512-UWFH6SrzNtzfvusGUFYxXDrgsUEbtBXkH/66hpDWxjA2Ckt7ozcYIujZpshbr7LPy8kV3ZRxIvoyCMdaS5DkVQ==
dependencies:
"@types/node" "^8.0.24"
"@types/node" "^10.12.18"
electron-download "^4.1.0"
extract-zip "^1.0.3"

Expand Down Expand Up @@ -6896,11 +6897,6 @@ punycode@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d"

punycode@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

q-i@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/q-i/-/q-i-2.0.1.tgz#fec7e3f0e713f3467358bb5ac80bcc4c115187d6"
Expand Down

0 comments on commit ae161c6

Please sign in to comment.