Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(electron): Update Modals Plugin to use new dialog async syntax #2742

Merged
merged 1 commit into from Apr 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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