Refactor and Move RedactedBodyView To Shared Components (#32772)

* refactoring and creation of shared-components for reductedBodyView

* move redacted message rendering to shared MVVM view

* Update snapshots + fix lint errors

* Remove MatrixClientPeg and use reguler react matrix client context

* Stop resyncing redacted body view models with mxEvent

* Fix redacted_because test fixtures for stricter event typing

* Simplify redacted body client access

* Watch timestamp setting in redacted body view model

* Refactor redacted and decryption failure body factories into MBodyFactory

* Prettier Fix

* Refactor FileBody into same pattern for consitancy
This commit is contained in:
Zack
2026-03-24 10:02:07 +00:00
committed by GitHub
parent d7843bb9b8
commit 4f3a1a2cc6
30 changed files with 688 additions and 159 deletions
@@ -42,6 +42,7 @@ import { Action } from "../../../../../src/dispatcher/actions";
import PinningUtils from "../../../../../src/utils/PinningUtils";
import { Layout } from "../../../../../src/settings/enums/Layout";
import { ScopedRoomContextProvider } from "../../../../../src/contexts/ScopedRoomContext.tsx";
import SettingsStore from "../../../../../src/settings/SettingsStore";
describe("EventTile", () => {
const ROOM_ID = "!roomId:example.org";
@@ -94,6 +95,7 @@ describe("EventTile", () => {
jest.spyOn(client, "getRoom").mockReturnValue(room);
jest.spyOn(client, "decryptEventIfNeeded").mockResolvedValue();
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
mxEvent = mkMessage({
room: room.roomId,
@@ -220,6 +222,22 @@ describe("EventTile", () => {
expect(container.getElementsByClassName("mx_EventTile_details")[0]).toHaveTextContent("@alice:example.org");
});
it("renders the shared redacted body for thread previews", () => {
jest.spyOn(mxEvent, "isRedacted").mockReturnValue(true);
jest.spyOn(mxEvent, "getUnsigned").mockReturnValue({
redacted_because: {
sender: "@moderator:example.org",
origin_server_ts: Date.UTC(2022, 10, 17, 15, 58, 32),
},
} as any);
const { container } = getComponent({}, TimelineRenderingType.ThreadsList);
const redactedBody = container.querySelector(".mx_RedactedBody");
expect(redactedBody).not.toBeNull();
expect(redactedBody).toHaveTextContent("Message deleted by @moderator:example.org");
});
it.each([
[TimelineRenderingType.Notification, Action.ViewRoom],
[TimelineRenderingType.ThreadsList, Action.ShowThread],