From aaa9b7761c71fb63774b3422854fb8d99c48b72c Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Tue, 4 Jul 2023 11:26:54 +0100 Subject: [PATCH] Use `widget` with `!` instead of `?` It cannot be `null` in the mentioned contexts as discussed with Robin. --- src/room/GroupCallView.tsx | 12 ++++++------ src/room/InCallView.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index db61a536..8d5341ac 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -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) => { 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]); diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 598dc7f3..f96b8a92 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -204,11 +204,11 @@ export function InCallView({ if (widget) { const onTileLayout = async (ev: CustomEvent) => { setLayout("freedom"); - await widget?.api.transport.reply(ev.detail, {}); + await widget!.api.transport.reply(ev.detail, {}); }; const onSpotlightLayout = async (ev: CustomEvent) => { setLayout("spotlight"); - await widget?.api.transport.reply(ev.detail, {}); + await widget!.api.transport.reply(ev.detail, {}); }; widget.lazyActions.on(ElementWidgetActions.TileLayout, onTileLayout); @@ -218,8 +218,8 @@ export function InCallView({ ); return () => { - widget?.lazyActions.off(ElementWidgetActions.TileLayout, onTileLayout); - widget?.lazyActions.off( + widget!.lazyActions.off(ElementWidgetActions.TileLayout, onTileLayout); + widget!.lazyActions.off( ElementWidgetActions.SpotlightLayout, onSpotlightLayout );