diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-25 14:00:02 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-25 14:00:02 +0200 |
commit | 89315fa530e1f21e2e50d94f955693b9413c98fe (patch) | |
tree | bc0747aa1b4f53147030be26c24d079fb0b34001 /MatrixRoomUtils.Web/Classes/RoomInfo.cs | |
parent | Clean up MRUStorageWrapper (diff) | |
download | MatrixUtils-89315fa530e1f21e2e50d94f955693b9413c98fe.tar.xz |
New things
Diffstat (limited to 'MatrixRoomUtils.Web/Classes/RoomInfo.cs')
-rw-r--r-- | MatrixRoomUtils.Web/Classes/RoomInfo.cs | 12 |
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) => { |