Show tombstone message in tombstoned room (#195)
authorajbura <ajbura@gmail.com>
Sat, 5 Feb 2022 13:29:44 +0000 (18:59 +0530)
committerajbura <ajbura@gmail.com>
Sat, 5 Feb 2022 13:29:44 +0000 (18:59 +0530)
Signed-off-by: ajbura <ajbura@gmail.com>
src/app/organisms/room/RoomViewInput.jsx

index d574d86bb2e69d23aa888752e392f28624f04b51..37e0298938ebcd72cd532770b62fb34d31c1ec72 100644 (file)
@@ -303,12 +303,18 @@ function RoomViewInput({
     if (file !== null) roomsInput.setAttachment(roomId, file);
   }
 
-  const canISend = roomTimeline.room.currentState.maySendMessage(mx.getUserId());
-
   function renderInputs() {
-    if (!canISend) {
+    const canISend = roomTimeline.room.currentState.maySendMessage(mx.getUserId());
+    const tombstoneEvent = roomTimeline.room.currentState.getStateEvents('m.room.tombstone')[0];
+    if (!canISend || tombstoneEvent) {
       return (
-        <Text className="room-input__alert">You do not have permission to post to this room</Text>
+        <Text className="room-input__alert">
+          {
+            tombstoneEvent
+              ? tombstoneEvent.getContent()?.body ?? 'This room has been replaced and is no longer active.'
+              : 'You do not have permission to post to this room'
+          }
+        </Text>
       );
     }
     return (