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:
Richard van der Hoff
2025-04-30 16:56:21 +01:00
committed by GitHub
parent ce1055f5fe
commit f25fbdebc7
41 changed files with 345 additions and 315 deletions
+5 -4
View File
@@ -679,7 +679,7 @@ export default class LegacyCallHandler extends TypedEventEmitter<LegacyCallHandl
private showICEFallbackPrompt(): void {
const cli = MatrixClientPeg.safeGet();
Modal.createDialog(
const { finished } = Modal.createDialog(
QuestionDialog,
{
title: _t("voip|misconfigured_server"),
@@ -703,13 +703,14 @@ export default class LegacyCallHandler extends TypedEventEmitter<LegacyCallHandl
server: new URL(FALLBACK_ICE_SERVER).pathname,
}),
cancelButton: _t("action|ok"),
onFinished: (allow) => {
SettingsStore.setValue("fallbackICEServerAllowed", null, SettingLevel.DEVICE, allow);
},
},
undefined,
true,
);
finished.then(([allow]) => {
SettingsStore.setValue("fallbackICEServerAllowed", null, SettingLevel.DEVICE, allow);
});
}
private showMediaCaptureError(call: MatrixCall): void {