From fba448ac2d4c46dc7b04c438dd793bd4c923b8cb Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Fri, 27 Sep 2013 16:33:49 -0700 Subject: [PATCH 1/5] Notify render processes when updates are available --- src/atom-application.coffee | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index dd09dcef6..55a7b86a1 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -24,6 +24,7 @@ socketPath = '/tmp/atom.sock' module.exports = class AtomApplication _.extend @prototype, EventEmitter.prototype + updateAvailable: false # Public: The entry point into the Atom application. @open: (options) -> @@ -148,6 +149,9 @@ class AtomApplication autoUpdater.on 'ready-for-update-on-quit', (event, version, quitAndUpdateCallback) => event.preventDefault() @applicationMenu.showDownloadUpdateItem(version, quitAndUpdateCallback) + for window in @windows + browserWindow = window.browserWindow + ipc.sendChannel browserWindow.getProcessId(), browserWindow.getRoutingId(), 'command', 'window:update-available', version # A request from the associated render process to open a new render process. ipc.on 'open', (processId, routingId, options) => @@ -231,7 +235,7 @@ class AtomApplication else resourcePath = @resourcePath bootstrapScript = require.resolve('./window-bootstrap') - openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode}) + openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode, @updateAvailable}) if pidToKillWhenClosed? @pidsToOpenWindows[pidToKillWhenClosed] = openedWindow @@ -261,7 +265,7 @@ class AtomApplication console.log "Joining session #{sessionId}" if sessionId bootstrapScript = 'collaboration/lib/bootstrap' - new AtomWindow({bootstrapScript, @resourcePath, sessionId, devMode}) + new AtomWindow({bootstrapScript, @resourcePath, sessionId, devMode, @updateAvailable}) else console.log "Opening unknown url #{urlToOpen}" @@ -285,7 +289,7 @@ class AtomApplication isSpec = true devMode = true - new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specDirectory}) + new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specDirectory, @updateAvailable}) runBenchmarks: -> try @@ -294,7 +298,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}) + new AtomWindow({bootstrapScript, @resourcePath, isSpec, @updateAvailable}) # Private: Opens a native dialog to prompt the user for a path. # From 0d1e1c6fc6b8cc07e338f39e0bbaf8deeda19422 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Fri, 27 Sep 2013 17:10:06 -0700 Subject: [PATCH 2/5] Add missing line to set updateAvailable --- src/atom-application.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 55a7b86a1..048a9b44c 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -150,6 +150,7 @@ class AtomApplication event.preventDefault() @applicationMenu.showDownloadUpdateItem(version, quitAndUpdateCallback) for window in @windows + @updateAvailable = true browserWindow = window.browserWindow ipc.sendChannel browserWindow.getProcessId(), browserWindow.getRoutingId(), 'command', 'window:update-available', version From 6dc6f1b7acedadad27c6d6c28ea410dbd35b37cd Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Mon, 30 Sep 2013 11:17:43 -0700 Subject: [PATCH 3/5] 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) From 4dd22c6ab451d55cb6802e44db598babc967e2a0 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 1 Oct 2013 15:58:45 -0700 Subject: [PATCH 4/5] Include release-notes by default --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9845e6868..374695dbe 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "markdown-preview": "0.6.0", "metrics": "0.7.0", "package-generator": "0.10.0", + "release-notes": "0.2.0", "settings-view": "0.25.0", "snippets": "0.6.0", "spell-check": "0.6.0", From 074eb3fd6971be17eeb20064ec7df53a2c9155c6 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 1 Oct 2013 16:18:35 -0700 Subject: [PATCH 5/5] Don't pass updateVersion to AtomWindow --- src/atom-application.coffee | 13 +++++++++---- src/atom-window.coffee | 7 +++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 846b5805a..a4f019dcb 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -234,7 +234,7 @@ class AtomApplication else resourcePath = @resourcePath bootstrapScript = require.resolve('./window-bootstrap') - openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode, @updateVersion}) + openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode}) if pidToKillWhenClosed? @pidsToOpenWindows[pidToKillWhenClosed] = openedWindow @@ -264,7 +264,7 @@ class AtomApplication console.log "Joining session #{sessionId}" if sessionId bootstrapScript = 'collaboration/lib/bootstrap' - new AtomWindow({bootstrapScript, @resourcePath, sessionId, devMode, @updateVersion}) + new AtomWindow({bootstrapScript, @resourcePath, sessionId, devMode}) else console.log "Opening unknown url #{urlToOpen}" @@ -288,7 +288,7 @@ class AtomApplication isSpec = true devMode = true - new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specDirectory, @updateVersion}) + new AtomWindow({bootstrapScript, resourcePath, exitWhenDone, isSpec, devMode, specDirectory}) runBenchmarks: -> try @@ -297,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, @updateVersion}) + new AtomWindow({bootstrapScript, @resourcePath, isSpec}) # Private: Opens a native dialog to prompt the user for a path. # @@ -310,3 +310,8 @@ class AtomApplication promptForPath: ({devMode}={}) -> pathsToOpen = dialog.showOpenDialog title: 'Open', properties: ['openFile', 'openDirectory', 'multiSelections', 'createDirectory'] @openPaths({pathsToOpen, devMode}) + + # Public: If an update is available, it returns the new version string + # otherwise it returns null. + getUpdateVersion: -> + @updateVersion diff --git a/src/atom-window.coffee b/src/atom-window.coffee index 3e242bb22..9e82a3542 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -2,7 +2,6 @@ BrowserWindow = require 'browser-window' Menu = require 'menu' MenuItem = require 'menu-item' ContextMenu = require 'context-menu' -app = require 'app' dialog = require 'dialog' ipc = require 'ipc' path = require 'path' @@ -17,7 +16,7 @@ class AtomWindow isSpec: null constructor: (settings={}) -> - {@resourcePath, pathToOpen, initialLine, @isSpec, @updateVersion} = settings + {@resourcePath, pathToOpen, initialLine, @isSpec} = settings global.atomApplication.addWindow(this) @setupNodePath(@resourcePath) @@ -28,7 +27,7 @@ class AtomWindow @handleEvents() - loadSettings = _.omit(settings, 'updateVersion') + loadSettings = _.extend({}, settings) loadSettings.windowState ?= '' loadSettings.initialPath = pathToOpen try @@ -96,7 +95,7 @@ class AtomWindow if @loaded @focus() @sendCommand('window:open-path', {pathToOpen, initialLine}) - @sendCommand('window:update-available', @updateVersion) if @updateVersion + @sendCommand('window:update-available', global.atomApplication.getUpdateVersion()) if global.atomApplication.getUpdateVersion() else @browserWindow.once 'window:loaded', => @openPath(pathToOpen, initialLine)