mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-27 03:58:30 +00:00
Modal: remove support for onFinished callback (#29852)
* Fix up type for `finished` result of Modal The `finished` promise can be called with an empty array, for example if the dialog is closed by a background click. This was not correctly represented in the typing. Fix that, and add some documentation while we're at it. * Type fixes to onFinished callbacks from Modal These can all be called with zero arguments, despite what the type annotations may say, so mark them accordingly. * Remove uses of Modal `onFinished` property ... because it is confusing. Instead, use the `finished` promise returned by `createDialog`. * Modal: remove support for now-unused `onFinished` prop * StopGapWidgetDriver: use `await` instead of promise chaining * Fix up unit tests
This commit is contained in:
committed by
GitHub
parent
ce1055f5fe
commit
f25fbdebc7
@@ -34,34 +34,36 @@ const onReject = (): void => {
|
||||
};
|
||||
|
||||
const onLearnMoreNoOptIn = (): void => {
|
||||
showAnalyticsLearnMoreDialog({
|
||||
onFinished: (buttonClicked?: ButtonClicked) => {
|
||||
if (buttonClicked === ButtonClicked.Primary) {
|
||||
// user clicked "Enable"
|
||||
onAccept();
|
||||
}
|
||||
// otherwise, the user either clicked "Cancel", or closed the dialog without making a choice,
|
||||
// leave the toast open
|
||||
},
|
||||
const { finished } = showAnalyticsLearnMoreDialog({
|
||||
primaryButton: _t("action|enable"),
|
||||
});
|
||||
|
||||
finished.then(([buttonClicked]) => {
|
||||
if (buttonClicked === ButtonClicked.Primary) {
|
||||
// user clicked "Enable"
|
||||
onAccept();
|
||||
}
|
||||
// otherwise, the user either clicked "Cancel", or closed the dialog without making a choice,
|
||||
// leave the toast open
|
||||
});
|
||||
};
|
||||
|
||||
const onLearnMorePreviouslyOptedIn = (): void => {
|
||||
showAnalyticsLearnMoreDialog({
|
||||
onFinished: (buttonClicked?: ButtonClicked) => {
|
||||
if (buttonClicked === ButtonClicked.Primary) {
|
||||
// user clicked "That's fine"
|
||||
onAccept();
|
||||
} else if (buttonClicked === ButtonClicked.Cancel) {
|
||||
// user clicked "Stop"
|
||||
onReject();
|
||||
}
|
||||
// otherwise, the user closed the dialog without making a choice, leave the toast open
|
||||
},
|
||||
const { finished } = showAnalyticsLearnMoreDialog({
|
||||
primaryButton: _t("analytics|accept_button"),
|
||||
cancelButton: _t("action|stop"),
|
||||
});
|
||||
|
||||
finished.then(([buttonClicked]) => {
|
||||
if (buttonClicked === ButtonClicked.Primary) {
|
||||
// user clicked "That's fine"
|
||||
onAccept();
|
||||
} else if (buttonClicked === ButtonClicked.Cancel) {
|
||||
// user clicked "Stop"
|
||||
onReject();
|
||||
}
|
||||
// otherwise, the user closed the dialog without making a choice, leave the toast open
|
||||
});
|
||||
};
|
||||
|
||||
const TOAST_KEY = "analytics";
|
||||
|
||||
+12
-12
@@ -32,27 +32,27 @@ export const showToast = (version: string, newVersion: string, releaseNotes?: st
|
||||
let acceptLabel = _t("update|see_changes_button");
|
||||
if (releaseNotes) {
|
||||
onAccept = () => {
|
||||
Modal.createDialog(QuestionDialog, {
|
||||
const { finished } = Modal.createDialog(QuestionDialog, {
|
||||
title: _t("update|release_notes_toast_title"),
|
||||
description: <pre>{releaseNotes}</pre>,
|
||||
button: _t("action|update"),
|
||||
onFinished: (update) => {
|
||||
if (update && PlatformPeg.get()) {
|
||||
PlatformPeg.get()!.installUpdate();
|
||||
}
|
||||
},
|
||||
});
|
||||
finished.then(([update]) => {
|
||||
if (update && PlatformPeg.get()) {
|
||||
PlatformPeg.get()!.installUpdate();
|
||||
}
|
||||
});
|
||||
};
|
||||
} else if (checkVersion(version) && checkVersion(newVersion)) {
|
||||
onAccept = () => {
|
||||
Modal.createDialog(ChangelogDialog, {
|
||||
const { finished } = Modal.createDialog(ChangelogDialog, {
|
||||
version,
|
||||
newVersion,
|
||||
onFinished: (update) => {
|
||||
if (update && PlatformPeg.get()) {
|
||||
PlatformPeg.get()!.installUpdate();
|
||||
}
|
||||
},
|
||||
});
|
||||
finished.then(([update]) => {
|
||||
if (update && PlatformPeg.get()) {
|
||||
PlatformPeg.get()!.installUpdate();
|
||||
}
|
||||
});
|
||||
};
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user