Internal changes to policy list viewer (extensibility), fix duplicating change handler for room list page (performance), use /state in room list page before sync
3 files changed, 22 insertions, 9 deletions
diff --git a/MatrixRoomUtils.Desktop/FileStorageProvider.cs b/MatrixRoomUtils.Abstractions/FileStorageProvider.cs
index 0429d1a..73d5604 100644
--- a/MatrixRoomUtils.Desktop/FileStorageProvider.cs
+++ b/MatrixRoomUtils.Abstractions/FileStorageProvider.cs
@@ -5,7 +5,7 @@ using LibMatrix.Extensions;
using LibMatrix.Interfaces.Services;
using Microsoft.Extensions.Logging;
-namespace MatrixRoomUtils.Desktop;
+namespace MatrixRoomUtils.Abstractions;
public class FileStorageProvider : IStorageProvider {
private readonly ILogger<FileStorageProvider> _logger;
@@ -17,7 +17,7 @@ public class FileStorageProvider : IStorageProvider {
/// </summary>
/// <param name="targetPath"></param>
public FileStorageProvider(string targetPath) {
- new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test");
+ // new Logger<FileStorageProvider>(new LoggerFactory()).LogInformation("test");
Console.WriteLine($"Initialised FileStorageProvider with path {targetPath}");
TargetPath = targetPath;
if (!Directory.Exists(targetPath)) {
diff --git a/MatrixRoomUtils.Abstractions/MatrixRoomUtils.Abstractions.csproj b/MatrixRoomUtils.Abstractions/MatrixRoomUtils.Abstractions.csproj
new file mode 100644
index 0000000..1665ff0
--- /dev/null
+++ b/MatrixRoomUtils.Abstractions/MatrixRoomUtils.Abstractions.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\LibMatrix\LibMatrix\LibMatrix.csproj" />
+ </ItemGroup>
+</Project>
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;
}
|