about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Classes')
-rw-r--r--MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs6
-rw-r--r--MatrixRoomUtils.Web/Classes/RoomInfo.cs12
2 files changed, 12 insertions, 6 deletions
diff --git a/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs
index 3223ec6..b6836c8 100644
--- a/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs
+++ b/MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs
@@ -7,8 +7,6 @@ namespace MatrixRoomUtils.Web.Classes;
 
 public class MRUStorageWrapper(TieredStorageService storageService, HomeserverProviderService homeserverProviderService, NavigationManager navigationManager) {
     public async Task<List<UserAuth>?> GetAllTokens() {
-        if (!await storageService.DataStorageProvider.ObjectExistsAsync("mru.tokens")) { }
-
         return await storageService.DataStorageProvider.LoadObjectAsync<List<UserAuth>>("mru.tokens") ??
                new List<UserAuth>();
     }
@@ -48,6 +46,10 @@ public class MRUStorageWrapper(TieredStorageService storageService, HomeserverPr
         return await homeserverProviderService.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken);
     }
 
+    public async Task<AuthenticatedHomeserverGeneric?> GetSession(UserAuth userAuth) {
+        return await homeserverProviderService.GetAuthenticatedWithToken(userAuth.Homeserver, userAuth.AccessToken);
+    }
+
     public async Task<AuthenticatedHomeserverGeneric?> GetCurrentSessionOrNavigate() {
         AuthenticatedHomeserverGeneric? session = null;
 
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) => {