diff --git a/src/components/structures/SpaceRoomView.tsx b/src/components/structures/SpaceRoomView.tsx index 22962ed36e..7b7b79c126 100644 --- a/src/components/structures/SpaceRoomView.tsx +++ b/src/components/structures/SpaceRoomView.tsx @@ -64,7 +64,6 @@ import AccessibleButton, { type ButtonEvent } from "../views/elements/Accessible import ErrorBoundary from "../views/elements/ErrorBoundary"; import Field from "../views/elements/Field"; import RoomFacePile from "../views/elements/RoomFacePile"; -import RoomName from "../views/elements/RoomName"; import RoomTopic from "../views/elements/RoomTopic"; import withValidation from "../views/elements/Validation"; import RoomInfoLine from "../views/rooms/RoomInfoLine"; @@ -76,6 +75,7 @@ import RightPanel from "./RightPanel"; import SpaceHierarchy, { showRoom } from "./SpaceHierarchy"; import { type RoomPermalinkCreator } from "../../utils/permalinks/Permalinks"; import SpacePillButton from "./SpacePillButton.tsx"; +import { useRoomName } from "../../hooks/useRoomName.ts"; interface IProps { space: Room; @@ -214,6 +214,7 @@ const SpaceLanding: React.FC<{ space: Room }> = ({ space }) => { const cli = useContext(MatrixClientContext); const myMembership = useMyRoomMembership(space); const userId = cli.getSafeUserId(); + const name = useRoomName(space); const storeIsShowingSpaceMembers = useCallback( () => @@ -273,12 +274,7 @@ const SpaceLanding: React.FC<{ space: Room }> = ({ space }) => {
- - {(name) => { - const tags = { name: () =>

{name}

}; - return _t("space|landing_welcome", {}, tags) as JSX.Element; - }} -
+ {_t("space|landing_welcome", {}, { name: () =>

{name}

})}
diff --git a/src/components/views/dialogs/SpacePreferencesDialog.tsx b/src/components/views/dialogs/SpacePreferencesDialog.tsx index 1c5cb1cde9..6925cadcf1 100644 --- a/src/components/views/dialogs/SpacePreferencesDialog.tsx +++ b/src/components/views/dialogs/SpacePreferencesDialog.tsx @@ -17,12 +17,12 @@ import StyledCheckbox from "../elements/StyledCheckbox"; import { useSettingValue } from "../../../hooks/useSettings"; import SettingsStore from "../../../settings/SettingsStore"; import { SettingLevel } from "../../../settings/SettingLevel"; -import RoomName from "../elements/RoomName"; import { SpacePreferenceTab } from "../../../dispatcher/payloads/OpenSpacePreferencesPayload"; import { type NonEmptyArray } from "../../../@types/common"; import SettingsTab from "../settings/tabs/SettingsTab"; import { SettingsSection } from "../settings/shared/SettingsSection"; import { SettingsSubsection, SettingsSubsectionText } from "../settings/shared/SettingsSubsection"; +import { useRoomName } from "../../../hooks/useRoomName.ts"; interface IProps { space: Room; @@ -60,6 +60,7 @@ const SpacePreferencesAppearanceTab: React.FC> = ({ space }; const SpacePreferencesDialog: React.FC = ({ space, onFinished }) => { + const name = useRoomName(space); const tabs: NonEmptyArray> = [ new Tab( SpacePreferenceTab.Appearance, @@ -77,9 +78,7 @@ const SpacePreferencesDialog: React.FC = ({ space, onFinished }) => { title={_t("common|preferences")} fixedWidth={false} > -

- -

+

{name}

{}} />
diff --git a/src/components/views/elements/RoomName.tsx b/src/components/views/elements/RoomName.tsx deleted file mode 100644 index 318b9db4f4..0000000000 --- a/src/components/views/elements/RoomName.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2024 New Vector Ltd. -Copyright 2021 The Matrix.org Foundation C.I.C. - -SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial -Please see LICENSE files in the repository root for full details. -*/ - -import React, { type JSX, useEffect, useState } from "react"; -import { type Room, RoomEvent } from "matrix-js-sdk/src/matrix"; - -import { useTypedEventEmitter } from "../../../hooks/useEventEmitter"; - -interface IProps { - room?: Room; - children?(this: void, name: string): JSX.Element; -} - -/** - * @deprecated use `useRoomName.ts` instead - */ -const RoomName = ({ room, children }: IProps): JSX.Element => { - const [name, setName] = useState(room?.name); - useTypedEventEmitter(room, RoomEvent.Name, () => { - setName(room?.name); - }); - useEffect(() => { - setName(room?.name); - }, [room]); - - if (children) return children(name ?? ""); - return <>{name || ""}; -}; - -export default RoomName; diff --git a/src/components/views/right_panel/RoomSummaryCardView.tsx b/src/components/views/right_panel/RoomSummaryCardView.tsx index be316fdd14..460f7859d2 100644 --- a/src/components/views/right_panel/RoomSummaryCardView.tsx +++ b/src/components/views/right_panel/RoomSummaryCardView.tsx @@ -46,10 +46,10 @@ import { _t } from "../../../languageHandler.tsx"; import RoomAvatar from "../avatars/RoomAvatar.tsx"; import { E2EStatus } from "../../../utils/ShieldUtils.ts"; import { type RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks.ts"; -import RoomName from "../elements/RoomName.tsx"; import { Linkify, topicToHtml } from "../../../HtmlUtils.tsx"; import { useRoomSummaryCardViewModel } from "../../viewmodels/right_panel/RoomSummaryCardViewModel.tsx"; import { useRoomTopicViewModel } from "../../viewmodels/right_panel/RoomSummaryCardTopicViewModel.tsx"; +import { useRoomName } from "../../../hooks/useRoomName.ts"; interface IProps { room: Room; @@ -131,6 +131,8 @@ const RoomSummaryCardView: React.FC = ({ searchTerm = "", }) => { const vm = useRoomSummaryCardViewModel(room, permalinkCreator, onSearchCancel); + // XXX: this name should be part of the view model + const name = useRoomName(room); // The search field is controlled and onSearchChange is debounced in RoomView, // so we need to set the value of the input right away @@ -142,19 +144,15 @@ const RoomSummaryCardView: React.FC = ({ const roomInfo = (
- - {(name) => ( - - {name} - - )} - + + {name} + = ({ room, onJoinButtonClicked, onRejectButton const joinRule = useRoomState(room, (state) => state.getJoinRule()); const cannotJoin = getEffectiveMembership(myMembership) === EffectiveMembership.Leave && joinRule !== JoinRule.Public; + const name = useRoomName(room); const viewLabs = (): void => defaultDispatcher.dispatch({ @@ -169,9 +170,7 @@ const RoomPreviewCard: FC = ({ room, onJoinButtonClicked, onRejectButton
{inviterSection}
{avatarRow}
-

- -

+

{name}

{room.getJoinRule() === "public" && } diff --git a/src/models/Call.ts b/src/models/Call.ts index cb9041bfec..535c04f2f2 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -721,7 +721,6 @@ export class ElementCall extends Call { // We can pass the raw EW analyticsID here since we need to trust EC with not sending sensitive data to posthog (EC has access to more sensible data than the analyticsID e.g. the username) const analyticsID: string = accountAnalyticsData?.pseudonymousAnalyticsOptIn ? accountAnalyticsData?.id : ""; - params.append("analyticsID", analyticsID); // Legacy, deprecated in favour of posthogUserId params.append("posthogUserId", analyticsID); params.append("posthogApiHost", posthogConfig.api_host); params.append("posthogApiKey", posthogConfig.project_api_key); diff --git a/src/utils/pages.ts b/src/utils/pages.ts index 4181e987f9..ea5488e8d2 100644 --- a/src/utils/pages.ts +++ b/src/utils/pages.ts @@ -6,7 +6,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import { logger } from "matrix-js-sdk/src/logger"; import { type MatrixClient } from "matrix-js-sdk/src/matrix"; import { type IConfigOptions } from "../IConfigOptions"; @@ -19,19 +18,6 @@ export function getHomePageUrl(appConfig: IConfigOptions, matrixClient: MatrixCl const pagesConfig = config.get("embedded_pages"); let pageUrl = pagesConfig ? new SnakedObject(pagesConfig).get("home_url") : null; - if (!pageUrl) { - // This is a deprecated config option for the home page - // (despite the name, given we also now have a welcome - // page, which is not the same). - pageUrl = (appConfig).welcomePageUrl; - if (pageUrl) { - logger.warn( - "You are using a deprecated config option: `welcomePageUrl`. Please use " + - "`embedded_pages.home_url` instead, per https://github.com/vector-im/element-web/issues/21428", - ); - } - } - if (!pageUrl) { pageUrl = getEmbeddedPagesWellKnown(matrixClient)?.home_url; } diff --git a/test/unit-tests/models/Call-test.ts b/test/unit-tests/models/Call-test.ts index 3231052645..39f44ed4eb 100644 --- a/test/unit-tests/models/Call-test.ts +++ b/test/unit-tests/models/Call-test.ts @@ -737,7 +737,6 @@ describe("ElementCall", () => { if (!(call instanceof ElementCall)) throw new Error("Failed to create call"); const urlParams = new URLSearchParams(new URL(call.widget.url).hash.slice(1)); - expect(urlParams.get("analyticsID")).toBe("123456789987654321"); expect(urlParams.get("posthogUserId")).toBe("123456789987654321"); expect(urlParams.get("posthogApiHost")).toBe("https://posthog"); expect(urlParams.get("posthogApiKey")).toBe("DEADBEEF");