about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Classes
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-08 13:55:15 +0100
committerRory& <root@rory.gay>2024-01-08 13:56:32 +0100
commitede3857084bc7c6e65b7d36cbf913b09596e2787 (patch)
treeb94694c307fb831ea5e63fabde0dbb5f56f02941 /MatrixRoomUtils.Web/Classes
parentSmall changes (diff)
downloadMatrixUtils-ede3857084bc7c6e65b7d36cbf913b09596e2787.tar.xz
Internal changes to policy list viewer (extensibility), fix duplicating change handler for room list page (performance), use /state in room list page before sync
Diffstat (limited to '')
-rw-r--r--MatrixRoomUtils.Abstractions/RoomInfo.cs (renamed from MatrixRoomUtils.Web/Classes/RoomInfo.cs)15
1 files changed, 8 insertions, 7 deletions
diff --git a/MatrixRoomUtils.Web/Classes/RoomInfo.cs b/MatrixRoomUtils.Abstractions/RoomInfo.cs

index 9d0cd59..6db3447 100644 --- a/MatrixRoomUtils.Web/Classes/RoomInfo.cs +++ b/MatrixRoomUtils.Abstractions/RoomInfo.cs
@@ -4,10 +4,9 @@ using ArcaneLibs; using LibMatrix; using LibMatrix.EventTypes.Spec.State; using LibMatrix.EventTypes.Spec.State.RoomInfo; -using LibMatrix.Interfaces; using LibMatrix.RoomTypes; -namespace MatrixRoomUtils.Web.Classes; +namespace MatrixRoomUtils.Abstractions; public class RoomInfo : NotifyPropertyChanged { public required GenericRoom Room { get; set; } @@ -44,7 +43,9 @@ public class RoomInfo : NotifyPropertyChanged { else @event.RawContent = default!; } - else throw; + else { + throw; + } } StateEvents.Add(@event); @@ -84,12 +85,12 @@ public class RoomInfo : NotifyPropertyChanged { public RoomInfo() { StateEvents.CollectionChanged += (_, args) => { if (args.NewItems is { Count: > 0 }) - foreach (StateEventResponse newState in args.NewItems) { - if (newState.GetType == typeof(RoomNameEventContent) && newState.TypedContent is RoomNameEventContent roomNameContent) + foreach (StateEventResponse newState in args.NewItems) { // TODO: switch statement benchmark? + if (newState.Type == RoomNameEventContent.EventId && newState.TypedContent is RoomNameEventContent roomNameContent) RoomName = roomNameContent.Name; - else if (newState.GetType == typeof(RoomAvatarEventContent) && newState.TypedContent is RoomAvatarEventContent roomAvatarContent) + else if (newState is { Type: RoomAvatarEventContent.EventId, TypedContent: RoomAvatarEventContent roomAvatarContent }) RoomIcon = roomAvatarContent.Url; - else if (newState.GetType == typeof(RoomCreateEventContent) && newState.TypedContent is RoomCreateEventContent roomCreateContent) { + else if (newState is { Type: RoomCreateEventContent.EventId, TypedContent: RoomCreateEventContent roomCreateContent }) { CreationEventContent = roomCreateContent; RoomCreator = newState.Sender; }