From 89315fa530e1f21e2e50d94f955693b9413c98fe Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Wed, 25 Oct 2023 14:00:02 +0200 Subject: New things --- MatrixRoomUtils.Web/Classes/MRUStorageWrapper.cs | 6 ++++-- MatrixRoomUtils.Web/Classes/RoomInfo.cs | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'MatrixRoomUtils.Web/Classes') 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?> GetAllTokens() { - if (!await storageService.DataStorageProvider.ObjectExistsAsync("mru.tokens")) { } - return await storageService.DataStorageProvider.LoadObjectAsync>("mru.tokens") ?? new List(); } @@ -48,6 +46,10 @@ public class MRUStorageWrapper(TieredStorageService storageService, HomeserverPr return await homeserverProviderService.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken); } + public async Task GetSession(UserAuth userAuth) { + return await homeserverProviderService.GetAuthenticatedWithToken(userAuth.Homeserver, userAuth.AccessToken); + } + public async Task 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 StateEvents { get; } = new(); public async Task 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(type, stateKey); + @event.RawContent = await Room.GetStateAsync(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) => { -- cgit 1.5.1