From 4c13fe0fc36b0dcba3f80b106a3d4c5eaac6b80b Mon Sep 17 00:00:00 2001 From: Mike S <13892112+Mike-Summ@users.noreply.github.com> Date: Fri, 10 Apr 2020 08:11:33 -0400 Subject: [PATCH] fix(electron): Update Modals Plugin to use new dialog async syntax (#2742) --- electron/src/electron/modals.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/electron/src/electron/modals.ts b/electron/src/electron/modals.ts index 002ca49dea..81052afd73 100644 --- a/electron/src/electron/modals.ts +++ b/electron/src/electron/modals.ts @@ -25,13 +25,8 @@ export class ModalsPluginElectron extends WebPlugin implements ModalsPlugin { } async alert(options: AlertOptions): Promise { - const alert = (message: string, title: string = '') => - { - let buttons = [options.buttonTitle || 'OK'] - dialog.showMessageBox(getCurrentWindow(), {message, title, buttons}); - } - alert(options.message, options.title); - return Promise.resolve(); + const buttons = [options.buttonTitle || 'OK']; + return await dialog.showMessageBox(getCurrentWindow(), {message: options.message, title: options.title, buttons}); } async prompt(options: PromptOptions): Promise { @@ -43,15 +38,9 @@ export class ModalsPluginElectron extends WebPlugin implements ModalsPlugin { } async confirm(options: ConfirmOptions): Promise { - const confirm = (message: string, title: string='') => - { - let buttons = [options.okButtonTitle || 'OK' , options.cancelButtonTitle || 'Cancel'] - return !dialog.showMessageBox(getCurrentWindow(), {message, title, buttons}); - } - const val = confirm(options.message,options.title); - return Promise.resolve({ - value: val - }); + const buttons = [options.okButtonTitle || 'OK' , options.cancelButtonTitle || 'Cancel']; + const value = await dialog.showMessageBox(getCurrentWindow(), {message: options.message, title: options.title, buttons}) + return {value: value.response === 0}; } async showActions(options: ActionSheetOptions): Promise {