diff --git a/lib/gui/app.js b/lib/gui/app.js index 6dc8ba9a..5f83aeb7 100644 --- a/lib/gui/app.js +++ b/lib/gui/app.js @@ -102,77 +102,75 @@ app.run(() => { version: currentVersion }) - settings.load().then(() => { - const shouldCheckForUpdates = updateNotifier.shouldCheckForUpdates({ - currentVersion, - lastSleptUpdateNotifier: settings.get('lastSleptUpdateNotifier'), - lastSleptUpdateNotifierVersion: settings.get('lastSleptUpdateNotifierVersion') + const shouldCheckForUpdates = updateNotifier.shouldCheckForUpdates({ + currentVersion, + lastSleptUpdateNotifier: settings.get('lastSleptUpdateNotifier'), + lastSleptUpdateNotifierVersion: settings.get('lastSleptUpdateNotifierVersion') + }) + + const isStableRelease = release.isStableRelease(currentVersion) + const updatesEnabled = settings.get('updatesEnabled') + + if (!shouldCheckForUpdates || !updatesEnabled) { + analytics.logEvent('Not checking for updates', { + shouldCheckForUpdates, + updatesEnabled, + stable: isStableRelease }) - const isStableRelease = release.isStableRelease(currentVersion) - const updatesEnabled = settings.get('updatesEnabled') + return Bluebird.resolve() + } - if (!shouldCheckForUpdates || !updatesEnabled) { - analytics.logEvent('Not checking for updates', { - shouldCheckForUpdates, - updatesEnabled, - stable: isStableRelease + const updateSemverRange = packageJSON.updates.semverRange + const includeUnstableChannel = settings.get('includeUnstableUpdateChannel') + + analytics.logEvent('Checking for updates', { + currentVersion, + stable: isStableRelease, + updateSemverRange, + includeUnstableChannel + }) + + return s3Packages.getLatestVersion(release.getReleaseType(currentVersion), { + range: updateSemverRange, + includeUnstableChannel + }).then((latestVersion) => { + if (semver.gte(currentVersion, latestVersion || '0.0.0')) { + analytics.logEvent('Update notification skipped', { + reason: 'Latest version' }) - return Bluebird.resolve() } - const updateSemverRange = packageJSON.updates.semverRange - const includeUnstableChannel = settings.get('includeUnstableUpdateChannel') + // In case the internet connection is not good and checking the + // latest published version takes too long, only show notify + // the user about the new version if he didn't start the flash + // process (e.g: selected an image), otherwise such interruption + // might be annoying. + if (selectionState.hasImage()) { + analytics.logEvent('Update notification skipped', { + reason: 'Image selected' + }) + return Bluebird.resolve() + } - analytics.logEvent('Checking for updates', { - currentVersion, - stable: isStableRelease, - updateSemverRange, - includeUnstableChannel + analytics.logEvent('Notifying update', { + latestVersion }) - return s3Packages.getLatestVersion(release.getReleaseType(currentVersion), { - range: updateSemverRange, - includeUnstableChannel - }).then((latestVersion) => { - if (semver.gte(currentVersion, latestVersion || '0.0.0')) { - analytics.logEvent('Update notification skipped', { - reason: 'Latest version' - }) - return Bluebird.resolve() - } + return updateNotifier.notify(latestVersion, { + allowSleepUpdateCheck: isStableRelease + }) - // In case the internet connection is not good and checking the - // latest published version takes too long, only show notify - // the user about the new version if he didn't start the flash - // process (e.g: selected an image), otherwise such interruption - // might be annoying. - if (selectionState.hasImage()) { - analytics.logEvent('Update notification skipped', { - reason: 'Image selected' - }) - return Bluebird.resolve() - } - - analytics.logEvent('Notifying update', { - latestVersion - }) - - return updateNotifier.notify(latestVersion, { - allowSleepUpdateCheck: isStableRelease - }) - - // If the error is an update user error, then we don't want - // to bother users each time they open the app. - // See: https://github.com/resin-io/etcher/issues/1525 - }).catch((error) => { - return errors.isUserError(error) && error.code === 'UPDATE_USER_ERROR' - }, (error) => { - analytics.logEvent('Update check user error', { - title: errors.getTitle(error), - description: errors.getDescription(error) - }) + // If the error is an update user error, then we don't want + // to bother users each time they open the app. + // See: https://github.com/resin-io/etcher/issues/1525 + }).catch((error) => { + return errors.isUserError(error) && error.code === 'UPDATE_USER_ERROR' + }, (error) => { + analytics.logEvent('Update check user error', { + title: errors.getTitle(error), + description: errors.getDescription(error) }) }).catch(exceptionReporter.report) }) @@ -347,3 +345,11 @@ app.controller('StateController', function ($rootScope, $scope) { */ this.currentName = null }) + +// Ensure user settings are loaded before +// we bootstrap the Angular.js application +angular.element(document).ready(() => { + settings.load().then(() => { + angular.bootstrap(document, [ 'Etcher' ]) + }).catch(exceptionReporter.report) +}) diff --git a/lib/gui/index.html b/lib/gui/index.html index 0df2d1b2..1fafeff7 100644 --- a/lib/gui/index.html +++ b/lib/gui/index.html @@ -8,7 +8,7 @@ -
+