Disable URL Preview setting if disabled on the homeserver (#33279)

* Disallow URL Previews if disabled by homeserver.

* Cleanup nonsense

* cleanup

* cleanup

* fixes

* Remove import

* Add an error handler

* cleanup
This commit is contained in:
Will Hunt
2026-04-28 15:08:22 +00:00
committed by GitHub
parent 72d316df79
commit 2b943768ea
8 changed files with 181 additions and 9 deletions
@@ -71,6 +71,7 @@ import ErrorDialog from "../../../../src/components/views/dialogs/ErrorDialog.ts
import * as pinnedEventHooks from "../../../../src/hooks/usePinnedEvents";
import { TimelineRenderingType } from "../../../../src/contexts/RoomContext";
import { ModuleApi } from "../../../../src/modules/Api";
import MatrixClientBackedController from "../../../../src/settings/controllers/MatrixClientBackedController.ts";
import { type ComposerInsertPayload, ComposerType } from "../../../../src/dispatcher/payloads/ComposerInsertPayload.ts";
// Used by group calls
@@ -93,6 +94,7 @@ describe("RoomView", () => {
beforeEach(() => {
mockPlatformPeg({ reload: () => {} });
cli = mocked(stubClient());
MatrixClientBackedController.matrixClient = cli;
const roomName = (expect.getState().currentTestName ?? "").replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
@@ -12,7 +12,13 @@ import userEvent from "@testing-library/user-event";
import PreferencesUserSettingsTab from "../../../../../../../src/components/views/settings/tabs/user/PreferencesUserSettingsTab";
import { MatrixClientPeg } from "../../../../../../../src/MatrixClientPeg";
import { mockPlatformPeg, stubClient } from "../../../../../../test-utils";
import {
getMockClientWithEventEmitter,
mockClientMethodsServer,
mockClientMethodsUser,
mockPlatformPeg,
stubClient,
} from "../../../../../../test-utils";
import SettingsStore from "../../../../../../../src/settings/SettingsStore";
import { SettingLevel } from "../../../../../../../src/settings/SettingLevel";
import MatrixClientBackedController from "../../../../../../../src/settings/controllers/MatrixClientBackedController";
@@ -29,6 +35,10 @@ describe("PreferencesUserSettingsTab", () => {
};
it("should render", () => {
MatrixClientBackedController.matrixClient = getMockClientWithEventEmitter({
...mockClientMethodsServer(),
...mockClientMethodsUser(),
});
const { asFragment } = renderTab();
expect(asFragment()).toMatchSnapshot();
});