mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
Properly handle invalid tombstone events and room shutdowns
This commit is contained in:
parent
43fa495821
commit
cefbed2ec4
2 changed files with 25 additions and 10 deletions
|
@ -102,6 +102,11 @@ export interface RoomNameEventContent {
|
|||
name?: string
|
||||
}
|
||||
|
||||
export interface RoomCanonicalAliasEventContent {
|
||||
alias?: RoomAlias | null
|
||||
alt_aliases?: RoomAlias[]
|
||||
}
|
||||
|
||||
export interface RoomTopicEventContent {
|
||||
topic?: string
|
||||
}
|
||||
|
|
|
@ -13,22 +13,32 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
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<HTMLAnchorElement, MouseEvent>) => {
|
||||
e.preventDefault()
|
||||
window.mainScreenContext.setActiveRoom(content.replacement_room)
|
||||
}
|
||||
let description: JSX.Element
|
||||
if (content.replacement_room?.length && content.replacement_room.startsWith("!")) {
|
||||
description = (
|
||||
<span>
|
||||
replaced this room with
|
||||
<a onClick={onClick} className="hicli-matrix-uri hicli-matrix-uri-room-alias">
|
||||
<span className="room-id">{content.replacement_room}</span>
|
||||
<a onClick={onClick} href={"matrix:roomid/" + content.replacement_room.slice(1)}
|
||||
className="hicli-matrix-uri">
|
||||
{content.replacement_room}
|
||||
</a>{end}
|
||||
</span>
|
||||
)
|
||||
return <div className="room-avatar-body">
|
||||
} else {
|
||||
description = <span>shut down this room{end}</span>
|
||||
}
|
||||
return <div className="room-tombstone-body">
|
||||
{sender?.content.displayname ?? event.sender} {description}
|
||||
</div>
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue