about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Classes/RoomInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Classes/RoomInfo.cs')
-rw-r--r--MatrixRoomUtils.Web/Classes/RoomInfo.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/MatrixRoomUtils.Web/Classes/RoomInfo.cs b/MatrixRoomUtils.Web/Classes/RoomInfo.cs
index 31943dc..a2fa6f5 100644
--- a/MatrixRoomUtils.Web/Classes/RoomInfo.cs
+++ b/MatrixRoomUtils.Web/Classes/RoomInfo.cs
@@ -1,4 +1,5 @@
 using System.Collections.ObjectModel;
+using System.Text.Json.Nodes;
 using ArcaneLibs;
 using LibMatrix;
 using LibMatrix.EventTypes.Spec.State;
@@ -8,7 +9,7 @@ using LibMatrix.RoomTypes;
 namespace MatrixRoomUtils.Web.Classes;
 
 public class RoomInfo : NotifyPropertyChanged {
-    public GenericRoom Room { get; set; }
+    public GenericRoom? Room { get; set; }
     public ObservableCollection<StateEventResponse?> StateEvents { get; } = new();
 
     public async Task<StateEventResponse?> GetStateEvent(string type, string stateKey = "") {
@@ -19,11 +20,12 @@ public class RoomInfo : NotifyPropertyChanged {
             Type = type,
             StateKey = stateKey
         };
+        if (Room is null) return null;
         try {
-            @event.TypedContent = await Room.GetStateAsync<EventContent>(type, stateKey);
+            @event.RawContent = await Room.GetStateAsync<JsonObject>(type, stateKey);
         }
         catch (MatrixException e) {
-            if (e is { ErrorCode: "M_NOT_FOUND" }) @event.TypedContent = default!;
+            if (e is { ErrorCode: "M_NOT_FOUND" }) @event.RawContent = default!;
             else throw;
         }
 
@@ -37,7 +39,7 @@ public class RoomInfo : NotifyPropertyChanged {
     }
 
     public string? RoomName {
-        get => _roomName ?? Room.RoomId;
+        get => _roomName ?? DefaultRoomName ?? Room.RoomId;
         set => SetField(ref _roomName, value);
     }
 
@@ -58,6 +60,8 @@ public class RoomInfo : NotifyPropertyChanged {
     private string? _roomName;
     private RoomCreateEventContent? _creationEventContent;
     private string? _roomCreator;
+    
+    public string? DefaultRoomName { get; set; }
 
     public RoomInfo() {
         StateEvents.CollectionChanged += (_, args) => {