From cefbed2ec42ac2f50a58385b86d99e78cf36d3b8 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Mon, 17 Mar 2025 11:00:11 +0000 Subject: [PATCH] Properly handle invalid tombstone events and room shutdowns --- web/src/api/types/mxtypes.ts | 5 ++++ .../ui/timeline/content/RoomTombstoneBody.tsx | 30 ++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/web/src/api/types/mxtypes.ts b/web/src/api/types/mxtypes.ts index 5089e7e..5242a8c 100644 --- a/web/src/api/types/mxtypes.ts +++ b/web/src/api/types/mxtypes.ts @@ -102,6 +102,11 @@ export interface RoomNameEventContent { name?: string } +export interface RoomCanonicalAliasEventContent { + alias?: RoomAlias | null + alt_aliases?: RoomAlias[] +} + export interface RoomTopicEventContent { topic?: string } diff --git a/web/src/ui/timeline/content/RoomTombstoneBody.tsx b/web/src/ui/timeline/content/RoomTombstoneBody.tsx index b38cb53..126ce49 100644 --- a/web/src/ui/timeline/content/RoomTombstoneBody.tsx +++ b/web/src/ui/timeline/content/RoomTombstoneBody.tsx @@ -13,22 +13,32 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +import { JSX } from "react" 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 = ( - + const end = content.body?.length > 0 ? ` with the message: ${content.body}` : "." + const onClick = (e: React.MouseEvent) => { + e.preventDefault() + window.mainScreenContext.setActiveRoom(content.replacement_room) + } + let description: JSX.Element + if (content.replacement_room?.length && content.replacement_room.startsWith("!")) { + description = ( + replaced this room with  - - {content.replacement_room} - {end} - - ) - return
+ + {content.replacement_room} + {end} + + ) + } else { + description = shut down this room{end} + } + return
{sender?.content.displayname ?? event.sender} {description}
}