From 43fa495821825f15c089acf597ea095491335a96 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Mon, 17 Mar 2025 00:58:59 +0000 Subject: [PATCH] Add a display for the m.room.tombstone event --- .../ui/timeline/content/RoomTombstoneBody.tsx | 36 +++++++++++++++++++ web/src/ui/timeline/content/index.ts | 5 +++ 2 files changed, 41 insertions(+) create mode 100644 web/src/ui/timeline/content/RoomTombstoneBody.tsx diff --git a/web/src/ui/timeline/content/RoomTombstoneBody.tsx b/web/src/ui/timeline/content/RoomTombstoneBody.tsx new file mode 100644 index 0000000..b38cb53 --- /dev/null +++ b/web/src/ui/timeline/content/RoomTombstoneBody.tsx @@ -0,0 +1,36 @@ +// gomuks - A Matrix client written in Go. +// Copyright (C) 2024 Nexus Nicholson +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +import { TombstoneEventContent } from "@/api/types" +import EventContentProps from "./props.ts" + +const RoomTombstoneBody = ({ event, sender }: EventContentProps) => { + const content = event.content as TombstoneEventContent + const end = content.body.length > 0 ? ` with the message: ${content.body}` : "." + const onClick = () => window.mainScreenContext.setActiveRoom(content.replacement_room) + const description = ( + + replaced this room with  + + {content.replacement_room} + {end} + + ) + return
+ {sender?.content.displayname ?? event.sender} {description} +
+} + +export default RoomTombstoneBody diff --git a/web/src/ui/timeline/content/index.ts b/web/src/ui/timeline/content/index.ts index c3931e9..92827fc 100644 --- a/web/src/ui/timeline/content/index.ts +++ b/web/src/ui/timeline/content/index.ts @@ -12,6 +12,7 @@ import PowerLevelBody from "./PowerLevelBody.tsx" import RedactedBody from "./RedactedBody.tsx" import RoomAvatarBody from "./RoomAvatarBody.tsx" import RoomNameBody from "./RoomNameBody.tsx" +import RoomTombstoneBody from "./RoomTombstoneBody.tsx" import TextMessageBody from "./TextMessageBody.tsx" import UnknownMessageBody from "./UnknownMessageBody.tsx" import EventContentProps from "./props.ts" @@ -31,6 +32,7 @@ export { default as RedactedBody } from "./RedactedBody.tsx" export { default as RoomAvatarBody } from "./RoomAvatarBody.tsx" export { default as RoomNameBody } from "./RoomNameBody.tsx" export { default as TextMessageBody } from "./TextMessageBody.tsx" +export { default as RoomTombstoneBody } from "./RoomTombstoneBody.tsx" export { default as UnknownMessageBody } from "./UnknownMessageBody.tsx" export type { default as EventContentProps } from "./props.ts" @@ -51,6 +53,8 @@ export function getBodyType(evt: MemDBEvent, forReply = false): React.FunctionCo return PinnedEventsBody case "m.room.power_levels": return PowerLevelBody + case "m.room.tombstone": + return RoomTombstoneBody } } else if (evt.state_key !== undefined) { // State events which must have a non-empty state key @@ -120,6 +124,7 @@ export function isSmallEvent(bodyType: React.FunctionComponent