Add getMenu method

This commit is contained in:
probablycorey
2014-04-07 10:21:25 -07:00
parent e21a1339a2
commit 33adaab8b1

View File

@@ -3,31 +3,30 @@ dialog = require 'dialog'
module.exports =
class AutoUpdateManager
constructor: (@applicationMenu) ->
constructor: ->
# Only released versions should check for updates.
return if /\w{7}/.test(@getVersion())
autoUpdater.setFeedUrl "https://atom.io/api/updates?version=#{@getVersion()}"
autoUpdater.on 'checking-for-update', =>
@applicationMenu.showDownloadingUpdateItem(false)
@applicationMenu.showInstallUpdateItem(false)
@applicationMenu.showCheckForUpdateItem(false)
@getMenu().showDownloadingUpdateItem(false)
@getMenu().showInstallUpdateItem(false)
@getMenu().showCheckForUpdateItem(false)
autoUpdater.on 'update-not-available', =>
@applicationMenu.showCheckForUpdateItem(true)
@getMenu().showCheckForUpdateItem(true)
autoUpdater.on 'update-available', =>
@applicationMenu.showDownloadingUpdateItem(true)
@getMenu().showDownloadingUpdateItem(true)
autoUpdater.on 'update-downloaded', (event, releaseNotes, releaseVersion, releaseDate, releaseURL) =>
for atomWindow in @getWindows()
atomWindow.sendCommand('window:update-available', [releaseVersion, releaseNotes])
@applicationMenu.showInstallUpdateItem(true)
@getMenu().showInstallUpdateItem(true)
autoUpdater.on 'error', (event, message) =>
@applicationMenu.showCheckForUpdateItem(true)
@getMenu().showCheckForUpdateItem(true)
# Check for update after Atom has fully started and the menus are created
setTimeout((-> autoUpdater.checkForUpdates()), 5000)
@@ -48,6 +47,9 @@ class AutoUpdateManager
autoUpdater.removeListener 'update-not-available', @onUpdateNotAvailable
dialog.showMessageBox type: 'warning', buttons: ['OK'], message: 'There was an error checking for updates.', detail: message
getMenu: ->
global.atomApplication.applicationMenu
getVersion: ->
global.atomApplication.version