fix: correctly implement AlertService.confirm API
This commit is contained in:
@@ -72,22 +72,24 @@ export class AlertService extends SNAlertService {
|
|||||||
title: string,
|
title: string,
|
||||||
confirmButtonText = 'Confirm',
|
confirmButtonText = 'Confirm',
|
||||||
cancelButtonText = 'Cancel',
|
cancelButtonText = 'Cancel',
|
||||||
onConfirm: () => void,
|
onConfirm?: () => void,
|
||||||
onCancel: () => void,
|
onCancel?: () => void,
|
||||||
destructive = false
|
destructive = false
|
||||||
) {
|
) {
|
||||||
const confirmed = await confirmDialog({
|
return confirmDialog({
|
||||||
text,
|
text,
|
||||||
title,
|
title,
|
||||||
confirmButtonText,
|
confirmButtonText,
|
||||||
cancelButtonText,
|
cancelButtonText,
|
||||||
confirmButtonStyle: destructive ? 'danger' : 'info'
|
confirmButtonStyle: destructive ? 'danger' : 'info'
|
||||||
});
|
}).then(confirmed => new Promise((resolve, reject) => {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
onConfirm();
|
onConfirm?.();
|
||||||
} else {
|
resolve(true);
|
||||||
onCancel();
|
} else {
|
||||||
}
|
onCancel?.();
|
||||||
return confirmed;
|
reject(false);
|
||||||
|
}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user