Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a756b33

Browse files
authored
Rename RoomCreate -> RoomPredecessorTile (#10047)
1 parent 2b66cfc commit a756b33

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

src/components/views/messages/RoomCreate.tsx renamed to src/components/views/messages/RoomPredecessorTile.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface IProps {
4040
* A message tile showing that this room was created as an upgrade of a previous
4141
* room.
4242
*/
43-
export const RoomCreate: React.FC<IProps> = ({ mxEvent, timestamp }) => {
43+
export const RoomPredecessorTile: React.FC<IProps> = ({ mxEvent, timestamp }) => {
4444
const msc3946ProcessDynamicPredecessor = SettingsStore.getValue("feature_dynamic_room_predecessors");
4545

4646
// Note: we ask the room for its predecessor here, instead of directly using
@@ -74,13 +74,14 @@ export const RoomCreate: React.FC<IProps> = ({ mxEvent, timestamp }) => {
7474

7575
if (!roomContext.room || roomContext.room.roomId !== mxEvent.getRoomId()) {
7676
logger.warn(
77-
"RoomCreate unexpectedly used outside of the context of the room containing this m.room.create event.",
77+
"RoomPredecessorTile unexpectedly used outside of the context of the" +
78+
"room containing this m.room.create event.",
7879
);
7980
return <></>;
8081
}
8182

8283
if (!predecessor) {
83-
logger.warn("RoomCreate unexpectedly used in a room with no predecessor.");
84+
logger.warn("RoomPredecessorTile unexpectedly used in a room with no predecessor.");
8485
return <div />;
8586
}
8687

src/events/EventTileFactory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import LegacyCallEvent from "../components/views/messages/LegacyCallEvent";
3434
import { CallEvent } from "../components/views/messages/CallEvent";
3535
import TextualEvent from "../components/views/messages/TextualEvent";
3636
import EncryptionEvent from "../components/views/messages/EncryptionEvent";
37-
import { RoomCreate } from "../components/views/messages/RoomCreate";
37+
import { RoomPredecessorTile } from "../components/views/messages/RoomPredecessorTile";
3838
import RoomAvatarEvent from "../components/views/messages/RoomAvatarEvent";
3939
import { WIDGET_LAYOUT_EVENT_TYPE } from "../stores/widgets/WidgetLayoutStore";
4040
import { ALL_RULE_TYPES } from "../mjolnir/BanList";
@@ -92,7 +92,7 @@ const HiddenEventFactory: Factory = (ref, props) => <HiddenBody ref={ref} {...pr
9292
// These factories are exported for reference comparison against pickFactory()
9393
export const JitsiEventFactory: Factory = (ref, props) => <MJitsiWidgetEvent ref={ref} {...props} />;
9494
export const JSONEventFactory: Factory = (ref, props) => <ViewSourceEvent ref={ref} {...props} />;
95-
export const RoomCreateEventFactory: Factory = (ref, props) => <RoomCreate {...props} />;
95+
export const RoomCreateEventFactory: Factory = (_ref, props) => <RoomPredecessorTile {...props} />;
9696

9797
const EVENT_TILE_TYPES = new Map<string, Factory>([
9898
[EventType.RoomMessage, MessageEventFactory], // note that verification requests are handled in pickFactory()

test/components/views/messages/RoomCreate-test.tsx renamed to test/components/views/messages/RoomPredecessorTile-test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { EventType, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
2222

2323
import dis from "../../../../src/dispatcher/dispatcher";
2424
import SettingsStore from "../../../../src/settings/SettingsStore";
25-
import { RoomCreate } from "../../../../src/components/views/messages/RoomCreate";
25+
import { RoomPredecessorTile } from "../../../../src/components/views/messages/RoomPredecessorTile";
2626
import { stubClient, upsertRoomStateEvents } from "../../../test-utils/test-utils";
2727
import { Action } from "../../../../src/dispatcher/actions";
2828
import RoomContext from "../../../../src/contexts/RoomContext";
@@ -31,7 +31,7 @@ import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
3131

3232
jest.mock("../../../../src/dispatcher/dispatcher");
3333

34-
describe("<RoomCreate />", () => {
34+
describe("<RoomPredecessorTile />", () => {
3535
const userId = "@alice:server.org";
3636
const roomId = "!room:server.org";
3737
const createEvent = new MatrixEvent({
@@ -97,34 +97,34 @@ describe("<RoomCreate />", () => {
9797
jest.spyOn(SettingsStore, "setValue").mockRestore();
9898
});
9999

100-
function renderRoomCreate(room: Room) {
100+
function renderTile(room: Room) {
101101
return render(
102102
<RoomContext.Provider value={getRoomContext(room, {})}>
103-
<RoomCreate mxEvent={createEvent} />
103+
<RoomPredecessorTile mxEvent={createEvent} />
104104
</RoomContext.Provider>,
105105
);
106106
}
107107

108108
it("Renders as expected", () => {
109-
const roomCreate = renderRoomCreate(roomJustCreate);
109+
const roomCreate = renderTile(roomJustCreate);
110110
expect(roomCreate.asFragment()).toMatchSnapshot();
111111
});
112112

113113
it("Links to the old version of the room", () => {
114-
renderRoomCreate(roomJustCreate);
114+
renderTile(roomJustCreate);
115115
expect(screen.getByText("Click here to see older messages.")).toHaveAttribute(
116116
"href",
117117
"https://matrix.to/#/old_room_id/tombstone_event_id",
118118
);
119119
});
120120

121121
it("Shows an empty div if there is no predecessor", () => {
122-
renderRoomCreate(roomNoPredecessors);
122+
renderTile(roomNoPredecessors);
123123
expect(screen.queryByText("Click here to see older messages.", { exact: false })).toBeNull();
124124
});
125125

126126
it("Opens the old room on click", async () => {
127-
renderRoomCreate(roomJustCreate);
127+
renderTile(roomJustCreate);
128128
const link = screen.getByText("Click here to see older messages.");
129129

130130
await act(() => userEvent.click(link));
@@ -142,7 +142,7 @@ describe("<RoomCreate />", () => {
142142
});
143143

144144
it("Ignores m.predecessor if labs flag is off", () => {
145-
renderRoomCreate(roomCreateAndPredecessor);
145+
renderTile(roomCreateAndPredecessor);
146146
expect(screen.getByText("Click here to see older messages.")).toHaveAttribute(
147147
"href",
148148
"https://matrix.to/#/old_room_id/tombstone_event_id",
@@ -161,23 +161,23 @@ describe("<RoomCreate />", () => {
161161
});
162162

163163
it("Uses the create event if there is no m.predecessor", () => {
164-
renderRoomCreate(roomJustCreate);
164+
renderTile(roomJustCreate);
165165
expect(screen.getByText("Click here to see older messages.")).toHaveAttribute(
166166
"href",
167167
"https://matrix.to/#/old_room_id/tombstone_event_id",
168168
);
169169
});
170170

171171
it("Uses m.predecessor when it's there", () => {
172-
renderRoomCreate(roomCreateAndPredecessor);
172+
renderTile(roomCreateAndPredecessor);
173173
expect(screen.getByText("Click here to see older messages.")).toHaveAttribute(
174174
"href",
175175
"https://matrix.to/#/old_room_id_from_predecessor",
176176
);
177177
});
178178

179179
it("Links to the event in the room if event ID is provided", () => {
180-
renderRoomCreate(roomCreateAndPredecessorWithEventId);
180+
renderTile(roomCreateAndPredecessorWithEventId);
181181
expect(screen.getByText("Click here to see older messages.")).toHaveAttribute(
182182
"href",
183183
"https://matrix.to/#/old_room_id_from_predecessor/tombstone_event_id_from_predecessor",

test/components/views/messages/__snapshots__/RoomCreate-test.tsx.snap renamed to test/components/views/messages/__snapshots__/RoomPredecessorTile-test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<RoomCreate /> Renders as expected 1`] = `
3+
exports[`<RoomPredecessorTile /> Renders as expected 1`] = `
44
<DocumentFragment>
55
<div
66
class="mx_EventTileBubble mx_CreateEvent"

0 commit comments

Comments
 (0)