From 5270eab5126d4410730e06950bb89376e87cfc3f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 15 Jun 2014 12:43:28 +0800 Subject: [PATCH] Do not assume trailing callback in dialog API, fixes #395. --- atom/browser/api/lib/dialog.coffee | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/lib/dialog.coffee b/atom/browser/api/lib/dialog.coffee index 369fed89de10..19cae0b3a2c4 100644 --- a/atom/browser/api/lib/dialog.coffee +++ b/atom/browser/api/lib/dialog.coffee @@ -26,11 +26,17 @@ module.exports = options.title ?= '' options.defaultPath ?= '' + wrappedCallback = + if typeof callback is 'function' + (success, result) -> callback(if success then result) + else + null + binding.showOpenDialog String(options.title), String(options.defaultPath), properties, window, - (success, result) -> callback if success then result + wrappedCallback showSaveDialog: (window, options, callback) -> unless window?.constructor is BrowserWindow @@ -43,10 +49,16 @@ module.exports = options.title ?= '' options.defaultPath ?= '' + wrappedCallback = + if typeof callback is 'function' + (success, result) -> callback(if success then result) + else + null + binding.showSaveDialog String(options.title), String(options.defaultPath), window, - (success, result) -> callback if success then result + wrappedCallback showMessageBox: (window, options, callback) -> unless window?.constructor is BrowserWindow