diff --git a/lib/package-manager.coffee b/lib/package-manager.coffee index 1a717bbf..182a1edd 100644 --- a/lib/package-manager.coffee +++ b/lib/package-manager.coffee @@ -13,7 +13,7 @@ class PackageManager @packagePromises = [] @apmCache = loadOutdated: - value: null + value: [] expiry: 0 @emitter = new Emitter @@ -132,6 +132,10 @@ class PackageManager # Short circuit if we have cached data. else if @apmCache.loadOutdated.value and @apmCache.loadOutdated.expiry > Date.now() return callback(null, @apmCache.loadOutdated.value) + # Return cached or empty package lists, if automatic updates are disabled, + # even if cache has expired, as long as no cache rebuilding is being forced. + else if (not atom.config.get('core.automaticallyUpdate')) + return callback(null, @apmCache.loadOutdated.value) args = ['outdated', '--json'] version = atom.getVersion() @@ -169,7 +173,7 @@ class PackageManager clearOutdatedCache: -> @apmCache.loadOutdated = - value: null + value: [] expiry: 0 loadPackage: (packageName, callback) -> diff --git a/lib/updates-panel.js b/lib/updates-panel.js index 424be5e8..fc9b1676 100644 --- a/lib/updates-panel.js +++ b/lib/updates-panel.js @@ -82,6 +82,10 @@ export default class UpdatesPanel {
The following packages are pinned to their current version and are not being checked for updates: { this.packageManager.getVersionPinnedPackages().join(', ') }
+
+ Automatically checking for updates is disabled. To enable, check the Automatically Update option + in { atom.workspace.open('atom://config/core') }}>Core settings. +
{`Checking for updates\u2026`}
All of your installed packages are up to date!
@@ -118,6 +122,12 @@ export default class UpdatesPanel { if (this.packageManager.getVersionPinnedPackages().length === 0) { this.refs.versionPinnedPackagesMessage.style.display = 'none' } + + if (atom.config.get('core.automaticallyUpdate')) { + this.refs.automaticallyUpdateDisabledMessage.style.display = 'none' + } else { + this.refs.automaticallyUpdateDisabledMessage.style.display = '' + } } // Check for updates and display them @@ -130,7 +140,7 @@ export default class UpdatesPanel { try { this.availableUpdates = await this.packageManager.getOutdated(clearCache) this.refs.checkButton.disabled = false - this.addUpdateViews() + this.addUpdateViews(clearCache) } catch (error) { this.refs.checkButton.disabled = false this.refs.checkingMessage.style.display = 'none' @@ -138,14 +148,14 @@ export default class UpdatesPanel { } } - addUpdateViews () { + addUpdateViews (forcedUpdate) { if (this.availableUpdates.length > 0) { this.refs.updateAllButton.style.display = '' this.refs.updateAllButton.disabled = false } this.refs.checkingMessage.style.display = 'none' this.clearPackageCards() - if (this.availableUpdates.length === 0) { + if (this.availableUpdates.length === 0 && (forcedUpdate || atom.config.get('core.automaticallyUpdate'))) { this.refs.noUpdatesMessage.style.display = '' }