Do not assume trailing callback in dialog API, fixes #395.
This commit is contained in:
parent
bf5fc2db9b
commit
5270eab512
1 changed files with 14 additions and 2 deletions
|
@ -26,11 +26,17 @@ module.exports =
|
||||||
options.title ?= ''
|
options.title ?= ''
|
||||||
options.defaultPath ?= ''
|
options.defaultPath ?= ''
|
||||||
|
|
||||||
|
wrappedCallback =
|
||||||
|
if typeof callback is 'function'
|
||||||
|
(success, result) -> callback(if success then result)
|
||||||
|
else
|
||||||
|
null
|
||||||
|
|
||||||
binding.showOpenDialog String(options.title),
|
binding.showOpenDialog String(options.title),
|
||||||
String(options.defaultPath),
|
String(options.defaultPath),
|
||||||
properties,
|
properties,
|
||||||
window,
|
window,
|
||||||
(success, result) -> callback if success then result
|
wrappedCallback
|
||||||
|
|
||||||
showSaveDialog: (window, options, callback) ->
|
showSaveDialog: (window, options, callback) ->
|
||||||
unless window?.constructor is BrowserWindow
|
unless window?.constructor is BrowserWindow
|
||||||
|
@ -43,10 +49,16 @@ module.exports =
|
||||||
options.title ?= ''
|
options.title ?= ''
|
||||||
options.defaultPath ?= ''
|
options.defaultPath ?= ''
|
||||||
|
|
||||||
|
wrappedCallback =
|
||||||
|
if typeof callback is 'function'
|
||||||
|
(success, result) -> callback(if success then result)
|
||||||
|
else
|
||||||
|
null
|
||||||
|
|
||||||
binding.showSaveDialog String(options.title),
|
binding.showSaveDialog String(options.title),
|
||||||
String(options.defaultPath),
|
String(options.defaultPath),
|
||||||
window,
|
window,
|
||||||
(success, result) -> callback if success then result
|
wrappedCallback
|
||||||
|
|
||||||
showMessageBox: (window, options, callback) ->
|
showMessageBox: (window, options, callback) ->
|
||||||
unless window?.constructor is BrowserWindow
|
unless window?.constructor is BrowserWindow
|
||||||
|
|
Loading…
Reference in a new issue