Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/hooks/room/useRoomCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import React, { type ReactNode, useCallback, useEffect, useMemo, useState } from "react";
import { CallType } from "matrix-js-sdk/src/webrtc/call";

import { useFeatureEnabled } from "../useSettings";
import { useFeatureEnabled, useSettingValue } from "../useSettings";
import SdkConfig from "../../SdkConfig";
import { useEventEmitter, useEventEmitterState } from "../useEventEmitter";
import LegacyCallHandler, { LegacyCallHandlerEvent } from "../../LegacyCallHandler";
Expand All @@ -33,7 +33,7 @@
import { CallStore, CallStoreEvent } from "../../stores/CallStore";
import { isVideoRoom } from "../../utils/video-rooms";
import { useGuestAccessInformation } from "./useGuestAccessInformation";
import SettingsStore from "../../settings/SettingsStore";

Check failure on line 36 in src/hooks/room/useRoomCall.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'SettingsStore' is defined but never used

Check failure on line 36 in src/hooks/room/useRoomCall.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'SettingsStore' is declared but its value is never read.
import { UIFeature } from "../../settings/UIFeature";
import { BetaPill } from "../../components/views/beta/BetaCard";
import { type InteractionName } from "../../PosthogTrackers";
Expand Down Expand Up @@ -102,6 +102,8 @@
} => {
// settings
const groupCallsEnabled = useFeatureEnabled("feature_group_calls");
const widgetsFeatureEnabled = useSettingValue(UIFeature.Widgets);
const voipFeatureEnabled = useSettingValue(UIFeature.Voip);
const useElementCallExclusively = useMemo(() => {
return SdkConfig.get("element_call").use_exclusively;
}, []);
Expand Down Expand Up @@ -285,8 +287,8 @@
// We hide the voice call button if it'd have the same effect as the video call button
let hideVoiceCallButton = isManagedHybridWidgetEnabled(room) || !callOptions.includes(PlatformCallType.LegacyCall);
let hideVideoCallButton = false;
// We hide both buttons if they require widgets but widgets are disabled.
if (memberCount > 2 && !SettingsStore.getValue(UIFeature.Widgets)) {
// We hide both buttons if they require widgets but widgets are disabled, or if the Voip feature is disabled.
if ((memberCount > 2 && !widgetsFeatureEnabled) || !voipFeatureEnabled) {
hideVoiceCallButton = true;
hideVideoCallButton = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,37 @@ describe("RoomHeader", () => {
expect(screen.queryByRole("button", { name: "Voice call" })).not.toBeInTheDocument();
});

describe("UIFeature.Voip disabled", () => {
beforeEach(() => {
SdkConfig.put({
setting_defaults: {
[UIFeature.Voip]: false,
},
});
});

afterEach(() => {
SdkConfig.reset();
jest.restoreAllMocks();
});

it("should not show call buttons in rooms smaller than 3 members", async () => {
mockRoomMembers(room, 2);
render(<RoomHeader room={room} />, getWrapper());

expect(screen.queryByRole("button", { name: "Video call" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Voice call" })).not.toBeInTheDocument();
});

it("should not show call button in rooms larger than 2 members", async () => {
mockRoomMembers(room, 3);
render(<RoomHeader room={room} />, getWrapper());

expect(screen.queryByRole("button", { name: "Video call" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Voice call" })).not.toBeInTheDocument();
});
});

describe("UIFeature.Widgets enabled (default)", () => {
beforeEach(() => {
SdkConfig.put({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
style="--cpd-icon-button-size: 100%; --cpd-color-icon-tertiary: var(--cpd-color-icon-disabled);"
>
<svg
aria-labelledby="«r1c8»"
aria-labelledby="«r1do»"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
Expand All @@ -71,7 +71,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
<button
aria-disabled="true"
aria-label="There's no one here to call"
aria-labelledby="«r1cd»"
aria-labelledby="«r1dt»"
class="_icon-button_m2erp_8"
role="button"
style="--cpd-icon-button-size: 32px;"
Expand All @@ -96,7 +96,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
</button>
<button
aria-label="Threads"
aria-labelledby="«r1ci»"
aria-labelledby="«r1e2»"
class="_icon-button_m2erp_8"
role="button"
style="--cpd-icon-button-size: 32px;"
Expand All @@ -122,7 +122,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
</button>
<button
aria-label="Room info"
aria-labelledby="«r1cn»"
aria-labelledby="«r1e7»"
class="_icon-button_m2erp_8"
role="button"
style="--cpd-icon-button-size: 32px;"
Expand Down
Loading