Skip to content

Commit 4c13fe0

Browse files
author
Mike S
authored
fix(electron): Update Modals Plugin to use new dialog async syntax (#2742)
1 parent 29a9acf commit 4c13fe0

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

electron/src/electron/modals.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ export class ModalsPluginElectron extends WebPlugin implements ModalsPlugin {
2525
}
2626

2727
async alert(options: AlertOptions): Promise<void> {
28-
const alert = (message: string, title: string = '') =>
29-
{
30-
let buttons = [options.buttonTitle || 'OK']
31-
dialog.showMessageBox(getCurrentWindow(), {message, title, buttons});
32-
}
33-
alert(options.message, options.title);
34-
return Promise.resolve();
28+
const buttons = [options.buttonTitle || 'OK'];
29+
return await dialog.showMessageBox(getCurrentWindow(), {message: options.message, title: options.title, buttons});
3530
}
3631

3732
async prompt(options: PromptOptions): Promise<PromptResult> {
@@ -43,15 +38,9 @@ export class ModalsPluginElectron extends WebPlugin implements ModalsPlugin {
4338
}
4439

4540
async confirm(options: ConfirmOptions): Promise<ConfirmResult> {
46-
const confirm = (message: string, title: string='') =>
47-
{
48-
let buttons = [options.okButtonTitle || 'OK' , options.cancelButtonTitle || 'Cancel']
49-
return !dialog.showMessageBox(getCurrentWindow(), {message, title, buttons});
50-
}
51-
const val = confirm(options.message,options.title);
52-
return Promise.resolve({
53-
value: val
54-
});
41+
const buttons = [options.okButtonTitle || 'OK' , options.cancelButtonTitle || 'Cancel'];
42+
const value = await dialog.showMessageBox(getCurrentWindow(), {message: options.message, title: options.title, buttons})
43+
return {value: value.response === 0};
5544
}
5645

5746
async showActions(options: ActionSheetOptions): Promise<ActionSheetResult> {

0 commit comments

Comments
 (0)