about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/RoomListComponents
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/RoomListComponents')
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor17
1 files changed, 14 insertions, 3 deletions
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
index 4be3c1f..709f2d7 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
@@ -1,12 +1,13 @@
 @using MatrixRoomUtils.Core.StateEventTypes
 @using MatrixRoomUtils.Core.StateEventTypes.Spec
+@using MatrixRoomUtils.Web.Classes.Constants
 <details>
     <summary>@roomType (@rooms.Count)</summary>
     @foreach (var room in rooms) {
         <div class="room-list-item">
             <RoomListItem RoomInfo="@room" ShowOwnProfile="@(roomType == "Room")"></RoomListItem>
-            @if (room.StateEvents.Any(x => x.Type == "m.room.create")) {
-                
+            @if (RoomVersionDangerLevel(room) != 0) {
+                <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton Color="@(RoomVersionDangerLevel(room) == 2 ? "#ff0000" : "#ff8800")" href="@($"/Rooms/Create?Import={room.Room.RoomId}")">Upgrade room</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton>
             }
             <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/Timeline")">View timeline</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton>
             <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton>
@@ -30,5 +31,15 @@
 
     private string roomType => Category.Key;
     private List<RoomInfo> rooms => Category.Value;
-    
+
+    private int RoomVersionDangerLevel(RoomInfo room) {
+        var roomVersion = room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.create");
+        if (roomVersion is null) return 0;
+        var roomVersionContent = roomVersion.TypedContent as RoomCreateEventData;
+        if (roomVersionContent is null) return 0;
+        if (RoomConstants.DangerousRoomVersions.Contains(roomVersionContent.RoomVersion)) return 2;
+        if (roomVersionContent.RoomVersion != RoomConstants.RecommendedRoomVersion) return 1;
+        return 0;
+    }
+
 }
\ No newline at end of file