Use widget with ! instead of ?

It cannot be `null` in the mentioned contexts as discussed with Robin.
This commit is contained in:
Daniel Abramov
2023-07-04 11:26:54 +01:00
parent 259ef27bd0
commit aaa9b7761c
2 changed files with 10 additions and 10 deletions

View File

@@ -140,14 +140,14 @@ export function GroupCallView({
PosthogAnalytics.instance.eventCallStarted.track(groupCall.groupCallId);
await Promise.all([
widget?.api.setAlwaysOnScreen(true),
widget?.api.transport.reply(ev.detail, {}),
widget!.api.setAlwaysOnScreen(true),
widget!.api.transport.reply(ev.detail, {}),
]);
};
widget.lazyActions.on(ElementWidgetActions.JoinCall, onJoin);
return () => {
widget?.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
widget!.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
};
}
}, [groupCall, preload, enter]);
@@ -206,12 +206,12 @@ export function GroupCallView({
if (widget && state === GroupCallState.Entered) {
const onHangup = async (ev: CustomEvent<IWidgetApiRequest>) => {
leave();
await widget?.api.transport.reply(ev.detail, {});
widget?.api.setAlwaysOnScreen(false);
await widget!.api.transport.reply(ev.detail, {});
widget!.api.setAlwaysOnScreen(false);
};
widget.lazyActions.once(ElementWidgetActions.HangupCall, onHangup);
return () => {
widget?.lazyActions.off(ElementWidgetActions.HangupCall, onHangup);
widget!.lazyActions.off(ElementWidgetActions.HangupCall, onHangup);
};
}
}, [groupCall, state, leave]);