Skip to content

Commit

Permalink
fix(electron): Update Modals Plugin to use new dialog async syntax (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike S authored Apr 10, 2020
1 parent 29a9acf commit 4c13fe0
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions electron/src/electron/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ export class ModalsPluginElectron extends WebPlugin implements ModalsPlugin {
}

async alert(options: AlertOptions): Promise<void> {
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<PromptResult> {
Expand All @@ -43,15 +38,9 @@ export class ModalsPluginElectron extends WebPlugin implements ModalsPlugin {
}

async confirm(options: ConfirmOptions): Promise<ConfirmResult> {
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<ActionSheetResult> {
Expand Down

0 comments on commit 4c13fe0

Please sign in to comment.