Refactor if expression (#2758)

Split the check on a boolean into another branch
This commit is contained in:
Andrew Ferrazzutti
2024-11-11 12:51:31 -05:00
committed by GitHub
parent 4b2d8403d7
commit f12e6601fe

View File

@@ -178,11 +178,14 @@ export const GroupCallView: FC<Props> = ({
}; };
if (skipLobby) { if (skipLobby) {
if (widget && preload) { if (widget) {
if (preload) {
// In preload mode without lobby we wait for a join action before entering // In preload mode without lobby we wait for a join action before entering
const onJoin = (ev: CustomEvent<IWidgetApiRequest>): void => { const onJoin = (ev: CustomEvent<IWidgetApiRequest>): void => {
(async (): Promise<void> => { (async (): Promise<void> => {
await defaultDeviceSetup(ev.detail.data as unknown as JoinCallData); await defaultDeviceSetup(
ev.detail.data as unknown as JoinCallData,
);
await enterRTCSession(rtcSession, perParticipantE2EE); await enterRTCSession(rtcSession, perParticipantE2EE);
widget!.api.transport.reply(ev.detail, {}); widget!.api.transport.reply(ev.detail, {});
})().catch((e) => { })().catch((e) => {
@@ -193,7 +196,7 @@ export const GroupCallView: FC<Props> = ({
return (): void => { return (): void => {
widget!.lazyActions.off(ElementWidgetActions.JoinCall, onJoin); widget!.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
}; };
} else if (widget && !preload) { } else {
// No lobby and no preload: we enter the rtc session right away // No lobby and no preload: we enter the rtc session right away
(async (): Promise<void> => { (async (): Promise<void> => {
await defaultDeviceSetup({ audioInput: null, videoInput: null }); await defaultDeviceSetup({ audioInput: null, videoInput: null });
@@ -201,6 +204,7 @@ export const GroupCallView: FC<Props> = ({
})().catch((e) => { })().catch((e) => {
logger.error("Error joining RTC session", e); logger.error("Error joining RTC session", e);
}); });
}
} else { } else {
void enterRTCSession(rtcSession, perParticipantE2EE); void enterRTCSession(rtcSession, perParticipantE2EE);
} }