Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/package-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PackageManager
@packagePromises = []
@apmCache =
loadOutdated:
value: null
value: []
expiry: 0

@emitter = new Emitter
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -169,7 +173,7 @@ class PackageManager

clearOutdatedCache: ->
@apmCache.loadOutdated =
value: null
value: []
expiry: 0

loadPackage: (packageName, callback) ->
Expand Down
16 changes: 13 additions & 3 deletions lib/updates-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export default class UpdatesPanel {
</div>

<div ref='versionPinnedPackagesMessage' className='alert alert-warning icon icon-alert'>The following packages are pinned to their current version and are not being checked for updates: <strong>{ this.packageManager.getVersionPinnedPackages().join(', ') }</strong></div>
<div ref='automaticallyUpdateDisabledMessage' className='alert alert-warning icon icon-alert'>
Automatically checking for updates is disabled. To enable, check the <em>Automatically Update</em> option
in <a class='link' onclick={() => { atom.workspace.open('atom://config/core') }}>Core settings</a>.
</div>
<div ref='updateErrors'></div>
<div ref='checkingMessage' className='alert alert-info icon icon-hourglass'>{`Checking for updates\u2026`}</div>
<div ref='noUpdatesMessage' className='alert alert-info icon icon-heart'>All of your installed packages are up to date!</div>
Expand Down Expand Up @@ -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
Expand All @@ -130,22 +140,22 @@ 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'
this.refs.updateErrors.appendChild(new ErrorView(this.packageManager, error).element)
}
}

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 = ''
}

Expand Down