Remove listeners after check for update is run.

This commit is contained in:
probablycorey
2014-03-04 10:17:55 -08:00
parent 6242bd7eb7
commit 084b41e33b

View File

@@ -154,27 +154,27 @@ class AtomApplication
setTimeout((-> autoUpdater.checkForUpdates()), 5000)
checkForUpdate: ->
autoUpdater.once 'update-available', ->
dialog.showMessageBox
type: 'info'
buttons: ['OK']
message: 'Update available.'
detail: 'A new update is being downloaded.'
removeListeners = =>
autoUpdater.removeListener 'update-available', @onUpdateAvailable
autoUpdater.removeListener 'update-not-available', @onUpdateNotAvailable
autoUpdater.removeListener 'error', @onUpdateError
autoUpdater.once 'update-not-available', =>
dialog.showMessageBox
type: 'info'
buttons: ['OK']
message: 'No update available.'
detail: "Version #{@version} is the latest version."
@onUpdateAvailable ?= =>
removeListeners()
dialog.showMessageBox type: 'info', buttons: ['OK'], message: 'Update available.', detail: 'A new update is being downloaded.'
autoUpdater.once 'error', (event, message)->
dialog.showMessageBox
type: 'warning'
buttons: ['OK']
message: 'There was an error checking for updates.'
detail: message
@onUpdateNotAvailable ?= =>
removeListeners()
dialog.showMessageBox type: 'info', buttons: ['OK'], message: 'No update available.', detail: "Version #{@version} is the latest version."
@onUpdateError ?= (event, message) =>
removeListeners()
dialog.showMessageBox type: 'warning', buttons: ['OK'], message: 'There was an error checking for updates.', detail: message
autoUpdater.on 'update-available', @onUpdateAvailable
autoUpdater.on 'update-not-available', @onUpdateNotAvailable
autoUpdater.on 'error', @onUpdateError
@applicationMenu.showCheckForUpdateItem(false)
autoUpdater.checkForUpdates()
# Registers basic application commands, non-idempotent.