review: just inline intent and skipLobby from urlParam
This commit is contained in:
@@ -77,7 +77,8 @@ export const RoomPage: FC = () => {
|
|||||||
scope,
|
scope,
|
||||||
devices,
|
devices,
|
||||||
calculateInitialMuteState(
|
calculateInitialMuteState(
|
||||||
urlParams,
|
urlParams.skipLobby,
|
||||||
|
urlParams.callIntent,
|
||||||
import.meta.env.VITE_PACKAGE,
|
import.meta.env.VITE_PACKAGE,
|
||||||
window.location.hostname,
|
window.location.hostname,
|
||||||
Config.get().trust_localhost_for_mute_state,
|
Config.get().trust_localhost_for_mute_state,
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ test.each<{
|
|||||||
"Should allow to unmute on start if not skipping lobby (callIntent: $callIntent, packageType: $packageType)",
|
"Should allow to unmute on start if not skipping lobby (callIntent: $callIntent, packageType: $packageType)",
|
||||||
({ callIntent, packageType }) => {
|
({ callIntent, packageType }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
{ skipLobby: false, callIntent },
|
false,
|
||||||
|
callIntent,
|
||||||
packageType,
|
packageType,
|
||||||
);
|
);
|
||||||
expect(audioEnabled).toBe(true);
|
expect(audioEnabled).toBe(true);
|
||||||
@@ -42,7 +43,8 @@ test.each<{
|
|||||||
"Should always mute on start if skipping lobby on non embedded build (callIntent: $callIntent)",
|
"Should always mute on start if skipping lobby on non embedded build (callIntent: $callIntent)",
|
||||||
({ callIntent }) => {
|
({ callIntent }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
{ skipLobby: true, callIntent },
|
true,
|
||||||
|
callIntent,
|
||||||
"full",
|
"full",
|
||||||
);
|
);
|
||||||
expect(audioEnabled).toBe(false);
|
expect(audioEnabled).toBe(false);
|
||||||
@@ -60,7 +62,8 @@ test.each<{
|
|||||||
"Can start unmuted if skipping lobby on embedded build (callIntent: $callIntent)",
|
"Can start unmuted if skipping lobby on embedded build (callIntent: $callIntent)",
|
||||||
({ callIntent }) => {
|
({ callIntent }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
{ skipLobby: true, callIntent },
|
true,
|
||||||
|
callIntent,
|
||||||
"embedded",
|
"embedded",
|
||||||
);
|
);
|
||||||
expect(audioEnabled).toBe(true);
|
expect(audioEnabled).toBe(true);
|
||||||
@@ -85,7 +88,8 @@ test.each<{
|
|||||||
"Should trust localhost domain when in dev mode isDevBuild($isDevBuild) host($currentHost)",
|
"Should trust localhost domain when in dev mode isDevBuild($isDevBuild) host($currentHost)",
|
||||||
({ isDevBuild, currentHost, expectedEnabled }) => {
|
({ isDevBuild, currentHost, expectedEnabled }) => {
|
||||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||||
{ skipLobby: true, callIntent: "video" },
|
true,
|
||||||
|
"video",
|
||||||
"full",
|
"full",
|
||||||
currentHost,
|
currentHost,
|
||||||
isDevBuild,
|
isDevBuild,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
|
import { type RTCCallIntent } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { type UrlParams } from "../UrlParams.ts";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the initial mute state for media devices based on configuration.
|
* Calculates the initial mute state for media devices based on configuration.
|
||||||
@@ -16,12 +15,12 @@ import { type UrlParams } from "../UrlParams.ts";
|
|||||||
* This function encapsulates the logic to determine the appropriate initial state.
|
* This function encapsulates the logic to determine the appropriate initial state.
|
||||||
*/
|
*/
|
||||||
export function calculateInitialMuteState(
|
export function calculateInitialMuteState(
|
||||||
urlParams: Pick<UrlParams, "skipLobby" | "callIntent">,
|
skipLobby: boolean,
|
||||||
|
callIntent: RTCCallIntent | undefined,
|
||||||
packageType: "full" | "embedded",
|
packageType: "full" | "embedded",
|
||||||
hostname: string | undefined = undefined,
|
hostname: string | undefined = undefined,
|
||||||
trustLocalhost: boolean = false,
|
trustLocalhost: boolean = false,
|
||||||
): { audioEnabled: boolean; videoEnabled: boolean } {
|
): { audioEnabled: boolean; videoEnabled: boolean } {
|
||||||
const { skipLobby, callIntent } = urlParams;
|
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent}, hostname=${hostname}, trustLocalhost=${trustLocalhost}`,
|
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent}, hostname=${hostname}, trustLocalhost=${trustLocalhost}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user