diff --git a/menus/darwin.cson b/menus/darwin.cson index f72552fac..e3681951c 100644 --- a/menus/darwin.cson +++ b/menus/darwin.cson @@ -7,6 +7,7 @@ { label: "VERSION", enabled: false } { label: "Restart and Install Update", command: 'application:install-update', visible: false} { label: "Check for Update", command: 'application:check-for-update', visible: false} + { label: "Downloading Update", command: 'application:check-for-update', enabled: false, visible: false} { type: 'separator' } { label: 'Preferences...', command: 'application:show-settings' } { label: 'Open Your Config', command: 'application:open-your-config' } diff --git a/src/browser/application-menu.coffee b/src/browser/application-menu.coffee index 905655ac8..b411551c4 100644 --- a/src/browser/application-menu.coffee +++ b/src/browser/application-menu.coffee @@ -71,11 +71,28 @@ class ApplicationMenu # Toggles Install Update Item showInstallUpdateItem: (visible=true) -> + if visible + @showDownloadingUpdateItem(false) + @showCheckForUpdateItem(false) + if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Restart and Install Update')) item.visible = visible + # Toggles Downloading Update Item + showDownloadingUpdateItem: (visible=true) -> + if visible + @showInstallUpdateItem(false) + @showCheckForUpdateItem(false) + + if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Downloading Update')) + item.visible = visible + # Toggles Check For Update Item showCheckForUpdateItem: (visible=true) -> + if visible + @showDownloadingUpdateItem(false) + @showInstallUpdateItem(false) + if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Check for Update')) item.visible = visible diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 02c67140b..ac0d13f4e 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -133,48 +133,38 @@ class AtomApplication autoUpdater.setFeedUrl "https://atom.io/api/updates?version=#{@version}" autoUpdater.on 'checking-for-update', => + @applicationMenu.showDownloadingUpdateItem(false) @applicationMenu.showInstallUpdateItem(false) @applicationMenu.showCheckForUpdateItem(false) autoUpdater.on 'update-not-available', => - @applicationMenu.showInstallUpdateItem(false) @applicationMenu.showCheckForUpdateItem(true) + autoUpdater.on 'update-available', => + @applicationMenu.showDownloadingUpdateItem(true) + autoUpdater.on 'update-downloaded', (event, releaseNotes, releaseName, releaseDate, releaseURL) => atomWindow.sendCommand('window:update-available', [releaseName, releaseNotes]) for atomWindow in @windows @applicationMenu.showInstallUpdateItem(true) - @applicationMenu.showCheckForUpdateItem(false) @updateVersion = releaseName autoUpdater.on 'error', (event, message) => - @applicationMenu.showInstallUpdateItem(false) @applicationMenu.showCheckForUpdateItem(true) # Check for update after Atom has fully started and the menus are created 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.' + @onUpdateNotAvailable ?= => + autoUpdater.removeListener 'error', @onUpdateError + dialog.showMessageBox type: 'info', buttons: ['OK'], message: 'No update available.', detail: "Version #{@version} is the latest version." - autoUpdater.once 'update-not-available', => - dialog.showMessageBox - type: 'info' - buttons: ['OK'] - message: 'No update available.' - detail: "Version #{@version} is the latest version." - - autoUpdater.once 'error', (event, message)-> - dialog.showMessageBox - type: 'warning' - buttons: ['OK'] - message: 'There was an error checking for updates.' - detail: message + @onUpdateError ?= (event, message) => + autoUpdater.removeListener 'update-not-available', @onUpdateNotAvailable + dialog.showMessageBox type: 'warning', buttons: ['OK'], message: 'There was an error checking for updates.', detail: message + autoUpdater.on 'update-not-available', @onUpdateNotAvailable + autoUpdater.on 'error', @onUpdateError autoUpdater.checkForUpdates() # Registers basic application commands, non-idempotent.