refactor: pass MessageBox params as a struct (#18732)
Historically, we've been passing in all MessageBox parameters individually, which makes augmenting or improving MessageBox functionality challenging because to change or add even one argument requires a huge cascade of argument changes that leaves room for errors. For other file dialog related APIs, we use a struct (DialogSettings), and so this PR takes a similar approach and refactors MessageBox parameters into a struct (MessageBoxSettings) which we then use to simplify argument passing and which will enable us to more quickly iterate and improve upon functionality in the future.
This commit is contained in:
parent
ffb53405fb
commit
bfcce8aa27
11 changed files with 207 additions and 247 deletions
|
@ -172,14 +172,25 @@ const messageBox = (sync, window, options) => {
|
|||
|
||||
const flags = options.noLink ? messageBoxOptions.noLink : 0
|
||||
|
||||
const settings = {
|
||||
window,
|
||||
messageBoxType,
|
||||
buttons,
|
||||
defaultId,
|
||||
cancelId,
|
||||
flags,
|
||||
title,
|
||||
message,
|
||||
detail,
|
||||
checkboxLabel,
|
||||
checkboxChecked,
|
||||
icon
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
return binding.showMessageBoxSync(messageBoxType, buttons,
|
||||
defaultId, cancelId, flags, title, message, detail,
|
||||
checkboxLabel, checkboxChecked, icon, window)
|
||||
return binding.showMessageBoxSync(settings)
|
||||
} else {
|
||||
return binding.showMessageBox(messageBoxType, buttons,
|
||||
defaultId, cancelId, flags, title, message, detail,
|
||||
checkboxLabel, checkboxChecked, icon, window)
|
||||
return binding.showMessageBox(settings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue