From ea1c66b3fc1a56422ed8f86076bc6c1d274aa26e Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 11 May 2016 22:02:59 +0200 Subject: [PATCH] Reduce delayedInit to 3 seconds --- config.js | 3 ++- main/index.js | 11 ++++++++++- renderer/index.js | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config.js b/config.js index ea891229..fc77ff6a 100644 --- a/config.js +++ b/config.js @@ -17,7 +17,6 @@ module.exports = { APP_VERSION: APP_VERSION, APP_WINDOW_TITLE: APP_NAME + ' (BETA)', - AUTO_UPDATE_CHECK_STARTUP_DELAY: 5 * 1000 /* 5 seconds */, AUTO_UPDATE_URL: 'https://webtorrent.io/desktop/update' + '?version=' + APP_VERSION + '&platform=' + process.platform, @@ -27,6 +26,8 @@ module.exports = { CONFIG_POSTER_PATH: path.join(getConfigPath(), 'Posters'), CONFIG_TORRENT_PATH: path.join(getConfigPath(), 'Torrents'), + DELAYED_INIT: 3000 /* 3 seconds */, + GITHUB_URL: 'https://github.com/feross/webtorrent-desktop', GITHUB_URL_ISSUES: 'https://github.com/feross/webtorrent-desktop/issues', GITHUB_URL_RAW: 'https://raw.githubusercontent.com/feross/webtorrent-desktop/master', diff --git a/main/index.js b/main/index.js index a496dba1..317a8de7 100644 --- a/main/index.js +++ b/main/index.js @@ -54,7 +54,6 @@ function init () { app.on('will-finish-launching', function () { crashReporter.init() - autoUpdater.init() }) app.on('ready', function () { @@ -64,6 +63,12 @@ function init () { shortcuts.init() tray.init() handlers.install() + + /* + * We always check for updates on app startup. To keep app startup fast, we delay this + * first check so it happens when there is less going on. + */ + setTimeout(delayedInit, config.DELAYED_INIT) }) app.on('ipcReady', function () { @@ -87,6 +92,10 @@ function init () { }) } +function delayedInit () { + autoUpdater.init() +} + function onOpen (e, torrentId) { e.preventDefault() diff --git a/renderer/index.js b/renderer/index.js index df15a0a8..53f4a256 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -65,7 +65,7 @@ function init () { resumeTorrents() // Lazy-load other stuff, like the AppleTV module, later to keep startup fast - window.setTimeout(delayedInit, 5000) + window.setTimeout(delayedInit, config.DELAYED_INIT) // The UI is built with virtual-dom, a minimalist library extracted from React // The concepts--one way data flow, a pure function that renders state to a