mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user