Do not use preload mode by default in embedded mode (#3488)
* Set preload=false by default for inApp * Pull through types for params so it's easy to document * Cleanup boolean logic * change test
This commit is contained in:
@@ -228,7 +228,7 @@ describe("UrlParams", () => {
|
|||||||
const startNewCallDefaults = (platform: string): object => ({
|
const startNewCallDefaults = (platform: string): object => ({
|
||||||
confineToRoom: true,
|
confineToRoom: true,
|
||||||
appPrompt: false,
|
appPrompt: false,
|
||||||
preload: true,
|
preload: false,
|
||||||
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
||||||
showControls: true,
|
showControls: true,
|
||||||
hideScreensharing: false,
|
hideScreensharing: false,
|
||||||
@@ -242,7 +242,7 @@ describe("UrlParams", () => {
|
|||||||
const joinExistingCallDefaults = (platform: string): object => ({
|
const joinExistingCallDefaults = (platform: string): object => ({
|
||||||
confineToRoom: true,
|
confineToRoom: true,
|
||||||
appPrompt: false,
|
appPrompt: false,
|
||||||
preload: true,
|
preload: false,
|
||||||
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
||||||
showControls: true,
|
showControls: true,
|
||||||
hideScreensharing: false,
|
hideScreensharing: false,
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ export const getUrlParams = (
|
|||||||
const inAppDefault = {
|
const inAppDefault = {
|
||||||
confineToRoom: true,
|
confineToRoom: true,
|
||||||
appPrompt: false,
|
appPrompt: false,
|
||||||
preload: true,
|
preload: false,
|
||||||
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
|
||||||
showControls: true,
|
showControls: true,
|
||||||
hideScreensharing: false,
|
hideScreensharing: false,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import { useRoomAvatar } from "./useRoomAvatar";
|
|||||||
import { useRoomName } from "./useRoomName";
|
import { useRoomName } from "./useRoomName";
|
||||||
import { useJoinRule } from "./useJoinRule";
|
import { useJoinRule } from "./useJoinRule";
|
||||||
import { InviteModal } from "./InviteModal";
|
import { InviteModal } from "./InviteModal";
|
||||||
import { HeaderStyle, useUrlParams } from "../UrlParams";
|
import { HeaderStyle, type UrlParams, useUrlParams } from "../UrlParams";
|
||||||
import { E2eeType } from "../e2ee/e2eeType";
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
import { useAudioContext } from "../useAudioContext";
|
import { useAudioContext } from "../useAudioContext";
|
||||||
import { callEventAudioSounds } from "./CallEventAudioRenderer";
|
import { callEventAudioSounds } from "./CallEventAudioRenderer";
|
||||||
@@ -83,8 +83,8 @@ interface Props {
|
|||||||
client: MatrixClient;
|
client: MatrixClient;
|
||||||
isPasswordlessUser: boolean;
|
isPasswordlessUser: boolean;
|
||||||
confineToRoom: boolean;
|
confineToRoom: boolean;
|
||||||
preload: boolean;
|
preload: UrlParams["preload"];
|
||||||
skipLobby: boolean;
|
skipLobby: UrlParams["skipLobby"];
|
||||||
header: HeaderStyle;
|
header: HeaderStyle;
|
||||||
rtcSession: MatrixRTCSession;
|
rtcSession: MatrixRTCSession;
|
||||||
isJoined: boolean;
|
isJoined: boolean;
|
||||||
@@ -276,34 +276,28 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (skipLobby) {
|
if (skipLobby) {
|
||||||
if (widget) {
|
if (widget && preload) {
|
||||||
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> => {
|
|
||||||
await defaultDeviceSetup(
|
|
||||||
ev.detail.data as unknown as JoinCallData,
|
|
||||||
);
|
|
||||||
await enterRTCSessionOrError(rtcSession);
|
|
||||||
widget.api.transport.reply(ev.detail, {});
|
|
||||||
})().catch((e) => {
|
|
||||||
logger.error("Error joining RTC session", e);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
widget.lazyActions.on(ElementWidgetActions.JoinCall, onJoin);
|
|
||||||
return (): void => {
|
|
||||||
widget.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// No lobby and no preload: we enter the rtc session right away
|
|
||||||
(async (): Promise<void> => {
|
(async (): Promise<void> => {
|
||||||
|
await defaultDeviceSetup(ev.detail.data as unknown as JoinCallData);
|
||||||
await enterRTCSessionOrError(rtcSession);
|
await enterRTCSessionOrError(rtcSession);
|
||||||
|
widget.api.transport.reply(ev.detail, {});
|
||||||
})().catch((e) => {
|
})().catch((e) => {
|
||||||
logger.error("Error joining RTC session", e);
|
logger.error("Error joining RTC session on preload", e);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
widget.lazyActions.on(ElementWidgetActions.JoinCall, onJoin);
|
||||||
|
return (): void => {
|
||||||
|
widget.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
void enterRTCSessionOrError(rtcSession);
|
// No lobby and no preload: we enter the rtc session right away
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
await enterRTCSessionOrError(rtcSession);
|
||||||
|
})().catch((e) => {
|
||||||
|
logger.error("Error joining RTC session immediately", e);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
@@ -494,6 +488,7 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
// Left in widget mode:
|
// Left in widget mode:
|
||||||
body = returnToLobby ? lobbyView : null;
|
body = returnToLobby ? lobbyView : null;
|
||||||
} else if (preload || skipLobby) {
|
} else if (preload || skipLobby) {
|
||||||
|
// The RTC session is not joined to yet (`isJoined`), but enterRTCSessionOrError should have been called.
|
||||||
body = null;
|
body = null;
|
||||||
} else {
|
} else {
|
||||||
body = lobbyView;
|
body = lobbyView;
|
||||||
|
|||||||
Reference in New Issue
Block a user