From 6dc6f1b7acedadad27c6d6c28ea410dbd35b37cd Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Mon, 30 Sep 2013 11:17:43 -0700 Subject: [PATCH] Call `window:update-available` on new AtomWindows --- src/atom-application.coffee | 16 +++++++--------- src/atom-window.coffee | 5 +++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 048a9b44c..846b5805a 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -24,7 +24,7 @@ socketPath = '/tmp/atom.sock' module.exports = class AtomApplication _.extend @prototype, EventEmitter.prototype - updateAvailable: false + updateVersion: null # Public: The entry point into the Atom application. @open: (options) -> @@ -148,11 +148,9 @@ class AtomApplication autoUpdater.on 'ready-for-update-on-quit', (event, version, quitAndUpdateCallback) => event.preventDefault() + @updateVersion = version @applicationMenu.showDownloadUpdateItem(version, quitAndUpdateCallback) - for window in @windows - @updateAvailable = true - browserWindow = window.browserWindow - ipc.sendChannel browserWindow.getProcessId(), browserWindow.getRoutingId(), 'command', 'window:update-available', version + atomWindow.sendCommand('window:update-available', version) for atomWindow in @windows # A request from the associated render process to open a new render process. ipc.on 'open', (processId, routingId, options) => @@ -236,7 +234,7 @@ class AtomApplication else resourcePath = @resourcePath bootstrapScript = require.resolve('./window-bootstrap') - openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode, @updateAvailable}) + openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode, @updateVersion}) if pidToKillWhenClosed? @pidsToOpenWindows[pidToKillWhenClosed] = openedWindow @@ -266,7 +264,7 @@ class AtomApplication console.log "Joining session #{sessionId}" if sessionId bootstrapScript = 'collaboration/lib/bootstrap' - new AtomWindow({bootstrapScript, @resourcePath, sessionId, devMode, @updateAvailable}) + new AtomWindow({bootstrapScript, @resourcePath, sessionId, devMode, @updateVersion}) else console.log "Opening unknown url #{urlToOpen}" @@ -290,7 +288,7 @@ class AtomApplication isSpec = true devMode = true - new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specDirectory, @updateAvailable}) + new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specDirectory, @updateVersion}) runBenchmarks: -> try @@ -299,7 +297,7 @@ class AtomApplication bootstrapScript = require.resolve(path.resolve(__dirname, '..', 'benchmark', 'benchmark-bootstrap')) isSpec = true # Needed because this flag adds the spec directory to the NODE_PATH - new AtomWindow({bootstrapScript, @resourcePath, isSpec, @updateAvailable}) + new AtomWindow({bootstrapScript, @resourcePath, isSpec, @updateVersion}) # Private: Opens a native dialog to prompt the user for a path. # diff --git a/src/atom-window.coffee b/src/atom-window.coffee index 5da1d3b2e..3e242bb22 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -17,7 +17,7 @@ class AtomWindow isSpec: null constructor: (settings={}) -> - {@resourcePath, pathToOpen, initialLine, @isSpec} = settings + {@resourcePath, pathToOpen, initialLine, @isSpec, @updateVersion} = settings global.atomApplication.addWindow(this) @setupNodePath(@resourcePath) @@ -28,7 +28,7 @@ class AtomWindow @handleEvents() - loadSettings = _.extend({}, settings) + loadSettings = _.omit(settings, 'updateVersion') loadSettings.windowState ?= '' loadSettings.initialPath = pathToOpen try @@ -96,6 +96,7 @@ class AtomWindow if @loaded @focus() @sendCommand('window:open-path', {pathToOpen, initialLine}) + @sendCommand('window:update-available', @updateVersion) if @updateVersion else @browserWindow.once 'window:loaded', => @openPath(pathToOpen, initialLine)