lint
This commit is contained in:
@@ -15,7 +15,7 @@ import { useSettingValue } from "../../../../../hooks/useSettings";
|
|||||||
import SettingsStore from "../../../../../settings/SettingsStore";
|
import SettingsStore from "../../../../../settings/SettingsStore";
|
||||||
import { SettingLevel } from "../../../../../settings/SettingLevel";
|
import { SettingLevel } from "../../../../../settings/SettingLevel";
|
||||||
|
|
||||||
export function MediaPreviewAccountSettings() {
|
export const MediaPreviewAccountSettings: React.FC = () => {
|
||||||
const currentMediaPreview = useSettingValue("mediaPreviewConfig");
|
const currentMediaPreview = useSettingValue("mediaPreviewConfig");
|
||||||
|
|
||||||
const avatarOnChange = useCallback(
|
const avatarOnChange = useCallback(
|
||||||
|
|||||||
@@ -386,7 +386,6 @@ export default class SettingsStore {
|
|||||||
const setting = SETTINGS[settingName];
|
const setting = SETTINGS[settingName];
|
||||||
const levelOrder = getLevelOrder(setting);
|
const levelOrder = getLevelOrder(setting);
|
||||||
|
|
||||||
|
|
||||||
return SettingsStore.getValueAt(levelOrder[0], settingName, roomId, false, excludeDefault);
|
return SettingsStore.getValueAt(levelOrder[0], settingName, roomId, false, excludeDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ describe("RoomAvatar", () => {
|
|||||||
const origFn = SettingsStore.getValue;
|
const origFn = SettingsStore.getValue;
|
||||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting, ...args) => {
|
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting, ...args) => {
|
||||||
if (setting === "mediaPreviewConfig") {
|
if (setting === "mediaPreviewConfig") {
|
||||||
return { invite_avatars: showAvatarsSetting, media_previews: MediaPreviewValue.Off};
|
return { invite_avatars: showAvatarsSetting, media_previews: MediaPreviewValue.Off };
|
||||||
}
|
}
|
||||||
return origFn(setting, ...args);
|
return origFn(setting, ...args);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ import { SettingLevel } from "../../../../../src/settings/SettingLevel";
|
|||||||
import type { Settings } from "../../../../../src/settings/Settings";
|
import type { Settings } from "../../../../../src/settings/Settings";
|
||||||
import { MediaPreviewValue } from "../../../../../src/@types/media_preview";
|
import { MediaPreviewValue } from "../../../../../src/@types/media_preview";
|
||||||
|
|
||||||
function mockSetting(
|
function mockSetting(mediaPreviews: MediaPreviewValue, showMediaEventIds: Settings["showMediaEventIds"]["default"]) {
|
||||||
mediaPreviews: MediaPreviewValue,
|
|
||||||
showMediaEventIds: Settings["showMediaEventIds"]["default"],
|
|
||||||
) {
|
|
||||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName) => {
|
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName) => {
|
||||||
if (settingName === "mediaPreviewConfig") {
|
if (settingName === "mediaPreviewConfig") {
|
||||||
return { media_previews: mediaPreviews, invite_avatars: MediaPreviewValue.Off };
|
return { media_previews: mediaPreviews, invite_avatars: MediaPreviewValue.Off };
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ describe("<MImageBody/>", () => {
|
|||||||
const origFn = SettingsStore.getValue;
|
const origFn = SettingsStore.getValue;
|
||||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting, ...args) => {
|
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting, ...args) => {
|
||||||
if (setting === "mediaPreviewConfig") {
|
if (setting === "mediaPreviewConfig") {
|
||||||
return { invite_avatars: MediaPreviewValue.Off, media_previews: MediaPreviewValue.Off};
|
return { invite_avatars: MediaPreviewValue.Off, media_previews: MediaPreviewValue.Off };
|
||||||
}
|
}
|
||||||
return origFn(setting, ...args);
|
return origFn(setting, ...args);
|
||||||
});
|
});
|
||||||
@@ -168,7 +168,7 @@ describe("<MImageBody/>", () => {
|
|||||||
mxEvent={encryptedMediaEvent}
|
mxEvent={encryptedMediaEvent}
|
||||||
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
||||||
/>,
|
/>,
|
||||||
withClientContextRenderOptions(cli)
|
withClientContextRenderOptions(cli),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText("Show image")).toBeInTheDocument();
|
expect(screen.getByText("Show image")).toBeInTheDocument();
|
||||||
@@ -185,7 +185,7 @@ describe("<MImageBody/>", () => {
|
|||||||
mxEvent={encryptedMediaEvent}
|
mxEvent={encryptedMediaEvent}
|
||||||
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
||||||
/>,
|
/>,
|
||||||
withClientContextRenderOptions(cli)
|
withClientContextRenderOptions(cli),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText("Show image")).toBeInTheDocument();
|
expect(screen.getByText("Show image")).toBeInTheDocument();
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ Please see LICENSE files in the repository root for full details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { act } from "react";
|
import React, { act } from "react";
|
||||||
import { EventType, getHttpUriForMxc, type IContent, MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
import { EventType, getHttpUriForMxc, type IContent, type MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||||
import { fireEvent, render, screen, type RenderResult } from "jest-matrix-react";
|
import { fireEvent, render, screen, type RenderResult } from "jest-matrix-react";
|
||||||
import fetchMock from "fetch-mock-jest";
|
import fetchMock from "fetch-mock-jest";
|
||||||
|
import { type MockedObject } from "jest-mock";
|
||||||
|
|
||||||
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
||||||
import { type RoomPermalinkCreator } from "../../../../../src/utils/permalinks/Permalinks";
|
import { type RoomPermalinkCreator } from "../../../../../src/utils/permalinks/Permalinks";
|
||||||
@@ -27,7 +28,6 @@ import type { IBodyProps } from "../../../../../src/components/views/messages/IB
|
|||||||
import { SettingLevel } from "../../../../../src/settings/SettingLevel";
|
import { SettingLevel } from "../../../../../src/settings/SettingLevel";
|
||||||
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
||||||
import { MediaPreviewValue } from "../../../../../src/@types/media_preview";
|
import { MediaPreviewValue } from "../../../../../src/@types/media_preview";
|
||||||
import { MockedObject } from "jest-mock";
|
|
||||||
|
|
||||||
// Needed so we don't throw an error about failing to decrypt.
|
// Needed so we don't throw an error about failing to decrypt.
|
||||||
jest.mock("matrix-encrypt-attachment", () => ({
|
jest.mock("matrix-encrypt-attachment", () => ({
|
||||||
@@ -107,7 +107,7 @@ describe("MVideoBody", () => {
|
|||||||
const origFn = SettingsStore.getValue;
|
const origFn = SettingsStore.getValue;
|
||||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting, ...args) => {
|
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting, ...args) => {
|
||||||
if (setting === "mediaPreviewConfig") {
|
if (setting === "mediaPreviewConfig") {
|
||||||
return { invite_avatars: MediaPreviewValue.Off, media_previews: MediaPreviewValue.Off};
|
return { invite_avatars: MediaPreviewValue.Off, media_previews: MediaPreviewValue.Off };
|
||||||
}
|
}
|
||||||
return origFn(setting, ...args);
|
return origFn(setting, ...args);
|
||||||
});
|
});
|
||||||
@@ -133,7 +133,7 @@ describe("MVideoBody", () => {
|
|||||||
mxEvent={encryptedMediaEvent}
|
mxEvent={encryptedMediaEvent}
|
||||||
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
||||||
/>,
|
/>,
|
||||||
withClientContextRenderOptions(cli)
|
withClientContextRenderOptions(cli),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText("Show video")).toBeInTheDocument();
|
expect(screen.getByText("Show video")).toBeInTheDocument();
|
||||||
@@ -149,7 +149,7 @@ describe("MVideoBody", () => {
|
|||||||
mxEvent={encryptedMediaEvent}
|
mxEvent={encryptedMediaEvent}
|
||||||
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
mediaEventHelper={new MediaEventHelper(encryptedMediaEvent)}
|
||||||
/>,
|
/>,
|
||||||
withClientContextRenderOptions(cli)
|
withClientContextRenderOptions(cli),
|
||||||
);
|
);
|
||||||
|
|
||||||
const placeholderButton = screen.getByRole("button", { name: "Show video" });
|
const placeholderButton = screen.getByRole("button", { name: "Show video" });
|
||||||
|
|||||||
Reference in New Issue
Block a user