From 20e81fdb1c7621b87008a053b31e46f501129870 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 11 Nov 2019 17:03:17 +0700 Subject: [PATCH] Migrate from deprecated APIs --- package-lock.json | 164 ++++++---------------------------------------- package.json | 4 +- source/browser.ts | 7 +- source/index.ts | 11 +--- source/tray.ts | 2 +- 5 files changed, 28 insertions(+), 160 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1c39e3b27..73db503a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -694,21 +694,21 @@ "dev": true }, "app-builder-lib": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-22.1.0.tgz", - "integrity": "sha512-jDTfWsVS/MePO4FexqiSQcsWM9Yfr81ETIYbmVbKmW05o0dn9k1DvMOMoLb0kTLQpW+pWBVvGMAOPfk68HnBrg==", + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-22.0.0.tgz", + "integrity": "sha512-4Q7JDb2lm6lNvtQxhjgjl2w9u3KuVOiNN6MFY46MWABkFbJbic8GDrQnktYPKOJ5p/KwV2itxcz6F+xAIgc15A==", "dev": true, "requires": { "7zip-bin": "~5.0.3", "@develar/schema-utils": "~2.1.0", "async-exit-hook": "^2.0.1", "bluebird-lst": "^1.0.9", - "builder-util": "22.1.0", + "builder-util": "22.0.0", "builder-util-runtime": "8.4.0", "chromium-pickle-js": "^0.2.0", "debug": "^4.1.1", "ejs": "^2.7.1", - "electron-publish": "22.1.0", + "electron-publish": "22.0.0", "fs-extra": "^8.1.0", "hosted-git-info": "^3.0.0", "is-ci": "^2.0.0", @@ -732,23 +732,6 @@ "ms": "^2.1.1" } }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - }, "hosted-git-info": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.2.tgz", @@ -1008,7 +991,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/boolean/-/boolean-2.0.3.tgz", "integrity": "sha512-iHzXeFCXWrpjYE7DToXGCBPGZf0eVISqzL+4sgrOSYEKXnb59WHPFvGTTyCj6zJ/MuuLAxEn8zPkrTHHzlt3IA==", - "dev": true + "dev": true, + "optional": true }, "boxen": { "version": "3.2.0", @@ -1129,9 +1113,9 @@ "dev": true }, "builder-util": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-22.1.0.tgz", - "integrity": "sha512-BPvpWvxQ5XOzm2WepIgmOAyo2IyaM/Bd1LJmeTYy5CtknNAtxgmAPQJfCHCikMKKQA4Obz/KYecXQiGpGJ2ThA==", + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-22.0.0.tgz", + "integrity": "sha512-fLTdykjOr1PWubJaj7LukaDJ1THqPkyTgJWswen6fn6TWUngZyDmAcg9hk4Aa1nf4BvyGx/iJCUhYjCkwpmimA==", "dev": true, "requires": { "7zip-bin": "~5.0.3", @@ -1158,23 +1142,6 @@ "ms": "^2.1.1" } }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -2175,23 +2142,6 @@ "mime": "^2.4.4" } }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - }, "iconv-lite": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.0.tgz", @@ -2341,14 +2291,14 @@ } }, "electron-builder": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-22.1.0.tgz", - "integrity": "sha512-uu2W9BLG38D0i2PG6dHupmOYc+q/TRL+Ztf8xitqK+2Quq33PFbeN0ipfySuVEDg4I6whDRBOgxBEWwnUYqZZQ==", + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-22.0.0.tgz", + "integrity": "sha512-OFqj5yYtEZBZwcOnyKe+YmL1VYNKw8o5lZlJAGQMX1xKzZPw8ZiaRZKVzn9k34ykANbz1FsBqwrt+lzVjrPIuQ==", "dev": true, "requires": { - "app-builder-lib": "22.1.0", + "app-builder-lib": "22.0.0", "bluebird-lst": "^1.0.9", - "builder-util": "22.1.0", + "builder-util": "22.0.0", "builder-util-runtime": "8.4.0", "chalk": "^2.4.2", "dmg-builder": "21.2.0", @@ -2359,25 +2309,6 @@ "sanitize-filename": "^1.6.3", "update-notifier": "^3.0.1", "yargs": "^14.0.0" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - } } }, "electron-context-menu": { @@ -2512,37 +2443,18 @@ "integrity": "sha512-kfV4riUqW8uooYLAfrlB3EJW66W29ePipJU4/Fm8UxQekVNcR2qHI/0tiJX3oWM79VdAUiiYqL9V49lhnSIO8g==" }, "electron-publish": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.1.0.tgz", - "integrity": "sha512-jHjMCaL2dFU+iOq8wW568F59+DW1jFJGT3vc2xqm9iXyZ8gWlQ+NVve4bq9HZG7m4iNqWbGw9StmZcOzmIBxMQ==", + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.0.0.tgz", + "integrity": "sha512-eeHa229kvvdl3OXbzE+d2xMTfHs3qOjQshF03vTyG19eFmvCx8eCkeCTEhT9QPb9kmkexV7FRAJpEwO2k1AtMA==", "dev": true, "requires": { "bluebird-lst": "^1.0.9", - "builder-util": "~22.1.0", + "builder-util": "~22.0.0", "builder-util-runtime": "8.4.0", "chalk": "^2.4.2", "fs-extra": "^8.1.0", "lazy-val": "^1.0.4", "mime": "^2.4.4" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - } } }, "electron-store": { @@ -7218,25 +7130,6 @@ "js-yaml": "^3.13.1", "json5": "^2.1.0", "lazy-val": "^1.0.4" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - } } }, "read-pkg": { @@ -8430,25 +8323,6 @@ "requires": { "async-exit-hook": "^2.0.1", "fs-extra": "^8.1.0" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", - "dev": true - } } }, "term-size": { diff --git a/package.json b/package.json index 394fd4854..2c2f7c9cf 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test": "npm run lint", "start": "tsc && electron .", "pack": "tsc && electron-builder --dir", - "dist": "tsc && electron-builder --macos --linux --windows", + "dist": "tsc && electron-builder --macos --linux --windows --config.snap.publish=github", "release": "np && npm run publish-snap", "publish-snap": "del dist && tsc && electron-builder --linux && snapcraft push --release=stable dist/*.snap" }, @@ -50,7 +50,7 @@ "@typescript-eslint/parser": "^2.6.1", "del-cli": "^3.0.0", "electron": "^7.1.1", - "electron-builder": "^22.1.0", + "electron-builder": "22.0.0", "eslint-config-xo-typescript": "^0.21.0", "husky": "^3.0.9", "np": "^5.1.3", diff --git a/source/browser.ts b/source/browser.ts index edf1dae57..25d7b4352 100644 --- a/source/browser.ts +++ b/source/browser.ts @@ -272,12 +272,13 @@ ipc.on('toggle-video-autoplay', () => { }); function setDarkMode(): void { - if (is.macos && config.get('followSystemAppearance')) { - document.documentElement.classList.toggle('dark-mode', api.systemPreferences.isDarkMode()); + if (config.get('followSystemAppearance')) { + api.nativeTheme.themeSource = 'system'; } else { - document.documentElement.classList.toggle('dark-mode', config.get('darkMode')); + api.nativeTheme.themeSource = config.get('darkMode') ? 'dark' : 'light'; } + document.documentElement.classList.toggle('dark-mode', api.nativeTheme.shouldUseDarkColors); updateVibrancy(); } diff --git a/source/index.ts b/source/index.ts index a9cea2085..be110207e 100644 --- a/source/index.ts +++ b/source/index.ts @@ -4,7 +4,6 @@ import { app, ipcMain, nativeImage, - systemPreferences, screen as electronScreen, session, shell, @@ -99,7 +98,7 @@ function updateBadge(conversations: Conversation[]): void { if (is.macos || is.linux) { if (config.get('showUnreadBadge') && !isDNDEnabled) { - app.setBadgeCount(messageCount); + app.badgeCount = messageCount; } if ( @@ -261,7 +260,7 @@ function createMainWindow(): BrowserWindow { 'https://www.messenger.com/login/'; const win = new BrowserWindow({ - title: app.getName(), + title: app.name, show: false, x: lastWindowState.x, y: lastWindowState.y, @@ -524,12 +523,6 @@ if (is.macos) { ipcMain.on('set-vibrancy', () => { mainWindow.setBackgroundColor('#00000000'); // Transparent, workaround for vibrancy issue. mainWindow.setVibrancy('sidebar'); - - if (config.get('followSystemAppearance')) { - systemPreferences.setAppLevelAppearance(systemPreferences.isDarkMode() ? 'dark' : 'light'); - } else { - systemPreferences.setAppLevelAppearance(config.get('darkMode') ? 'dark' : 'light'); - } }); } diff --git a/source/tray.ts b/source/tray.ts index 34409bf14..a3024c5a4 100644 --- a/source/tray.ts +++ b/source/tray.ts @@ -135,7 +135,7 @@ function updateToolTip(counter: number): void { return; } - let tooltip = app.getName(); + let tooltip = app.name; if (counter > 0) { tooltip += `- ${counter} unread ${counter === 1 ? 'message' : 'messages'}`;