Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove element call in forum room #1221

Open
wants to merge 1 commit into
base: develop_tchap
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 7 additions & 1 deletion src/components/views/rooms/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ import defaultDispatcher from "../../../dispatcher/dispatcher.ts";
import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog.tsx";
import { useScopedRoomContext } from "../../../contexts/ScopedRoomContext.tsx";

import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar"; // :TCHAP: customize-room-header-bar

import TchapUIFeature from "~tchap-web/src/tchap/util/TchapUIFeature"; // :TCHAP: customize-room-header-bar
import TchapExternalRoomHeader from "~tchap-web/src/tchap/components/views/rooms/TchapExternalRoomHeader"; // :TCHAP: customize-room-header-bar
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar"; // :TCHAP: customize-room-header-bar
import TchapRoomUtils from "~tchap-web/src/tchap/util/TchapRoomUtils.ts";
import { TchapRoomType } from "~tchap-web/src/tchap/@types/tchap.ts";



export default function RoomHeader({
room,
Expand Down Expand Up @@ -355,6 +360,7 @@ export default function RoomHeader({
{!isVideoRoom && videoCallButton}
*/ }
{!isDirectMessage && TchapUIFeature.isFeatureActiveForHomeserver("feature_video_group_call") &&
TchapRoomUtils.getTchapRoomType(room) !== TchapRoomType.Forum &&
!isVideoRoom && videoCallButton}

{isDirectMessage && TchapUIFeature.isFeatureActiveForHomeserver("feature_video_call") &&
Expand Down
20 changes: 20 additions & 0 deletions test/unit-tests/tchap/components/views/rooms/RoomHeaders-test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { KnownMembership, PendingEventOrdering, Room } from "matrix-js-sdk/src/matrix";
import { screen, render, RenderOptions, getByLabelText, queryByLabelText } from "jest-matrix-react";
import { mocked } from "jest-mock";

import { mkRoomMember, stubClient } from "~tchap-web/test/test-utils";
import RoomHeader from "~tchap-web/src/components/views/rooms/RoomHeader";
Expand All @@ -10,6 +11,10 @@ import MatrixClientContext from "~tchap-web/src/contexts/MatrixClientContext";
import SdkConfig from "~tchap-web/src/SdkConfig";
import SettingsStore from "~tchap-web/src/settings/SettingsStore";
import { UIFeature } from "~tchap-web/src/settings/UIFeature";
import TchapRoomUtils from "~tchap-web/src/tchap/util/TchapRoomUtils";
import { TchapRoomType } from "~tchap-web/src/tchap/@types/tchap";

jest.mock("~tchap-web/src/tchap/util/TchapRoomUtils");

function getWrapper(): RenderOptions {
return {
Expand Down Expand Up @@ -47,6 +52,7 @@ describe("RoomHeader", () => {
const featureVideoName: string = "feature_video_call";
const featureVideoGroupName: string = "feature_video_group_call";
const homeserverName: string = "my.home.server";
const mockedTchapRoomUtils = mocked(TchapRoomUtils);

const addHomeserverToMockConfig = (homeservers: string[], feature: string) => {
// mock SdkConfig.get("tchap_features")
Expand Down Expand Up @@ -89,6 +95,8 @@ describe("RoomHeader", () => {
(feature) => feature === "feature_group_calls" || feature == UIFeature.Widgets,
);

mockedTchapRoomUtils.getTchapRoomType.mockImplementation(() => TchapRoomType.Private);

DMRoomMap.setShared({
getUserIdForRoomId: jest.fn(),
} as unknown as DMRoomMap);
Expand Down Expand Up @@ -174,4 +182,16 @@ describe("RoomHeader", () => {

expect(queryByLabelText(container, "Video call")).toBeNull();
});

it("hides the video group when feature is activated but it is a forum", () => {
mockedTchapRoomUtils.getTchapRoomType.mockImplementation(() => TchapRoomType.Forum);

addHomeserverToMockConfig(["other.homeserver"], featureVideoGroupName);

mockRoomMembers(room, 4);

const { container } = getComponent();

expect(queryByLabelText(container, "Video call")).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`RoomHeader should render as expected 1`] = `
</span>
<div
aria-labelledby=":r0:"
class="mx_DecoratedRoomAvatar_icon mx_DecoratedRoomAvatar_icon_forum"
class="mx_DecoratedRoomAvatar_icon mx_DecoratedRoomAvatar_icon_private"
tabindex="0"
/>
</div>
Expand Down
Loading