about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-02-18 07:41:20 +0100
committerRory& <root@rory.gay>2025-02-18 07:41:20 +0100
commit373e3a481e9b16b328002426d416344a87ef1058 (patch)
tree17b50a14479099eba4b2ab490ffd5b28cd12c440
parentVarious changes (diff)
downloadMatrixUtils-373e3a481e9b16b328002426d416344a87ef1058.tar.xz
Some cleanup
-rw-r--r--Benchmarks/Program.cs5
m---------LibMatrix0
-rw-r--r--MatrixUtils.Abstractions/RoomInfo.cs8
-rw-r--r--MatrixUtils.Web/Classes/RMUStorageWrapper.cs37
-rw-r--r--MatrixUtils.Web/MatrixUtils.Web.csproj38
-rw-r--r--MatrixUtils.Web/Pages/Index.razor5
-rw-r--r--MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientRoomList.razor2
-rw-r--r--MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientStatusList.razor2
-rw-r--r--MatrixUtils.Web/Pages/Labs/Client/ClientComponents/MatrixClient.razor2
-rw-r--r--MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/MainTabComponents/MainTabSpaceItem.razor11
-rw-r--r--MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2ByRoomTypeTab.razor2
-rw-r--r--MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2DMsTab.razor2
-rw-r--r--MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2MainTab.razor2
-rw-r--r--MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2SyncContainer.razor4
-rw-r--r--MatrixUtils.Web/Pages/Rooms/Index.razor22
-rw-r--r--MatrixUtils.Web/Pages/Rooms/PolicyList.razor2
-rw-r--r--MatrixUtils.Web/Pages/Rooms/PolicyList2.razor2
-rw-r--r--MatrixUtils.Web/Pages/StreamTest.razor2
-rw-r--r--MatrixUtils.Web/Pages/Tools/Moderation/InviteCounter.razor24
-rw-r--r--MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor7
-rw-r--r--MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor3
-rw-r--r--MatrixUtils.Web/Pages/User/Profile.razor4
-rw-r--r--MatrixUtils.Web/Shared/InlineUserItem.razor1
-rw-r--r--MatrixUtils.Web/Shared/MxcAvatar.razor52
-rw-r--r--MatrixUtils.Web/Shared/MxcImage.razor82
-rw-r--r--MatrixUtils.Web/Shared/RoomList.razor5
-rw-r--r--MatrixUtils.Web/Shared/RoomListComponents/RoomListCategory.razor11
-rw-r--r--MatrixUtils.Web/Shared/RoomListComponents/RoomListSpace.razor11
-rw-r--r--MatrixUtils.Web/Shared/RoomListItem.razor20
-rw-r--r--MatrixUtils.Web/Shared/UserListItem.razor7
30 files changed, 206 insertions, 169 deletions
diff --git a/Benchmarks/Program.cs b/Benchmarks/Program.cs

index b85fc24..90d004a 100644 --- a/Benchmarks/Program.cs +++ b/Benchmarks/Program.cs
@@ -1,7 +1,10 @@ // See https://aka.ms/new-console-template for more information +using System; using System.Collections.Frozen; +using System.Collections.Generic; using System.Collections.Immutable; +using System.Linq; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Engines; @@ -262,7 +265,7 @@ public class Program { if (!DoDisambiguate || !DisambiguateKnockActions || !DisambiguateKnockRejected) _map[MembershipTransition.KnockRejected] = MembershipTransition.Leave; if (!DoDisambiguate || !DisambiguateKnockActions || !DisambiguateKnockRetracted) _map[MembershipTransition.KnockRetracted] = MembershipTransition.Leave; FrozenDictionary<MembershipTransition, MembershipTransition> map = _map.ToFrozenDictionary(); - _map = null!; + // _map foreach (var entry in entries) { var newState = map.TryGetValue(entry.State, out var value) ? value : entry.State; yield return newState == entry.State ? entry : entry with { State = newState }; diff --git a/LibMatrix b/LibMatrix -Subproject ca3e6878422b7b55ae52b43f49f89a19546ea51 +Subproject 8673cb236f427ba6af6382e3b5702a134f1afe2 diff --git a/MatrixUtils.Abstractions/RoomInfo.cs b/MatrixUtils.Abstractions/RoomInfo.cs
index 81ce388..4b2a53c 100644 --- a/MatrixUtils.Abstractions/RoomInfo.cs +++ b/MatrixUtils.Abstractions/RoomInfo.cs
@@ -12,13 +12,13 @@ namespace MatrixUtils.Abstractions; public class RoomInfo : NotifyPropertyChanged { public RoomInfo(GenericRoom room) { Room = room; - _fallbackIcon = identiconGenerator.GenerateAsDataUri(room.RoomId); + // _fallbackIcon = identiconGenerator.GenerateAsDataUri(room.RoomId); RegisterEventListener(); } public RoomInfo(GenericRoom room, List<StateEventResponse>? stateEvents) { Room = room; - _fallbackIcon = identiconGenerator.GenerateAsDataUri(room.RoomId); + // _fallbackIcon = identiconGenerator.GenerateAsDataUri(room.RoomId); if (stateEvents is { Count: > 0 }) StateEvents = new(stateEvents!); RegisterEventListener(); ProcessNewItems(stateEvents!); @@ -29,7 +29,7 @@ public class RoomInfo : NotifyPropertyChanged { public ObservableCollection<StateEventResponse?> Timeline { get; private set; } = new(); private static ConcurrentBag<AuthenticatedHomeserverGeneric> homeserversWithoutEventFormatSupport = new(); - private static SvgIdenticonGenerator identiconGenerator = new(); + // private static SvgIdenticonGenerator identiconGenerator = new(); public async Task<StateEventResponse?> GetStateEvent(string type, string stateKey = "") { if (homeserversWithoutEventFormatSupport.Contains(Room.Homeserver)) return await GetStateEventForged(type, stateKey); @@ -95,7 +95,7 @@ public class RoomInfo : NotifyPropertyChanged { } public string? RoomIcon { - get => _roomIcon ?? _fallbackIcon; + get => _roomIcon; set => SetField(ref _roomIcon, value); } diff --git a/MatrixUtils.Web/Classes/RMUStorageWrapper.cs b/MatrixUtils.Web/Classes/RMUStorageWrapper.cs
index e63c28e..1fc4dd1 100644 --- a/MatrixUtils.Web/Classes/RMUStorageWrapper.cs +++ b/MatrixUtils.Web/Classes/RMUStorageWrapper.cs
@@ -5,15 +5,19 @@ using Microsoft.AspNetCore.Components; namespace MatrixUtils.Web.Classes; -public class RMUStorageWrapper(ILogger<RMUStorageWrapper> logger, TieredStorageService storageService, HomeserverProviderService homeserverProviderService, NavigationManager navigationManager) { +public class RMUStorageWrapper( + ILogger<RMUStorageWrapper> logger, + TieredStorageService storageService, + HomeserverProviderService homeserverProviderService, + NavigationManager navigationManager) { public async Task<List<UserAuth>?> GetAllTokens() { logger.LogTrace("Getting all tokens."); return await storageService.DataStorageProvider.LoadObjectAsync<List<UserAuth>>("rmu.tokens") ?? new List<UserAuth>(); } - public async Task<UserAuth?> GetCurrentToken() { - logger.LogTrace("Getting current token."); + public async Task<UserAuth?> GetCurrentToken(bool log = true) { + if (log) logger.LogTrace("Getting current token."); var currentToken = await storageService.DataStorageProvider.LoadObjectAsync<UserAuth>("rmu.token"); var allTokens = await GetAllTokens(); if (allTokens is null or { Count: 0 }) { @@ -44,9 +48,9 @@ public class RMUStorageWrapper(ILogger<RMUStorageWrapper> logger, TieredStorageS await storageService.DataStorageProvider.SaveObjectAsync("rmu.tokens", tokens); } - private async Task<AuthenticatedHomeserverGeneric?> GetCurrentSession() { - logger.LogTrace("Getting current session."); - var token = await GetCurrentToken(); + private async Task<AuthenticatedHomeserverGeneric?> GetCurrentSession(bool log = true) { + if (log) logger.LogTrace("Getting current session."); + var token = await GetCurrentToken(log: false); if (token == null) { return null; } @@ -54,8 +58,8 @@ public class RMUStorageWrapper(ILogger<RMUStorageWrapper> logger, TieredStorageS return await GetSession(token); } - public async Task<AuthenticatedHomeserverGeneric?> GetSession(UserAuth userAuth) { - logger.LogTrace("Getting session."); + public async Task<AuthenticatedHomeserverGeneric?> GetSession(UserAuth userAuth, bool log = true) { + if (log) logger.LogTrace("Getting session."); AuthenticatedHomeserverGeneric hs; try { hs = await homeserverProviderService.GetAuthenticatedWithToken(userAuth.Homeserver, userAuth.AccessToken, userAuth.Proxy); @@ -65,11 +69,12 @@ public class RMUStorageWrapper(ILogger<RMUStorageWrapper> logger, TieredStorageS logger.LogError("Continuing with server-less session"); hs = await homeserverProviderService.GetAuthenticatedWithToken(userAuth.Homeserver, userAuth.AccessToken, userAuth.Proxy, useGeneric: true, enableServer: false); } + return hs; } - public async Task<AuthenticatedHomeserverGeneric?> GetCurrentSessionOrNavigate() { - logger.LogTrace("Getting current session or navigating."); + public async Task<AuthenticatedHomeserverGeneric?> GetCurrentSessionOrNavigate(bool log = true) { + if (log) logger.LogTrace("Getting current session or navigating."); AuthenticatedHomeserverGeneric? session = null; try { @@ -124,23 +129,23 @@ public class RMUStorageWrapper(ILogger<RMUStorageWrapper> logger, TieredStorageS public async Task MigrateFromMRU() { logger.LogInformation("Migrating from MRU token namespace!"); var dsp = storageService.DataStorageProvider!; - if(await dsp.ObjectExistsAsync("token")) { + if (await dsp.ObjectExistsAsync("token")) { var oldToken = await dsp.LoadObjectAsync<UserAuth>("token"); if (oldToken != null) { await dsp.SaveObjectAsync("rmu.token", oldToken); await dsp.DeleteObjectAsync("tokens"); } } - - if(await dsp.ObjectExistsAsync("tokens")) { + + if (await dsp.ObjectExistsAsync("tokens")) { var oldTokens = await dsp.LoadObjectAsync<List<UserAuth>>("tokens"); if (oldTokens != null) { await dsp.SaveObjectAsync("rmu.tokens", oldTokens); await dsp.DeleteObjectAsync("tokens"); } } - - if(await dsp.ObjectExistsAsync("mru.tokens")) { + + if (await dsp.ObjectExistsAsync("mru.tokens")) { var oldTokens = await dsp.LoadObjectAsync<List<UserAuth>>("mru.tokens"); if (oldTokens != null) { await dsp.SaveObjectAsync("rmu.tokens", oldTokens); @@ -148,4 +153,4 @@ public class RMUStorageWrapper(ILogger<RMUStorageWrapper> logger, TieredStorageS } } } -} +} \ No newline at end of file diff --git a/MatrixUtils.Web/MatrixUtils.Web.csproj b/MatrixUtils.Web/MatrixUtils.Web.csproj
index b472b45..acb4054 100644 --- a/MatrixUtils.Web/MatrixUtils.Web.csproj +++ b/MatrixUtils.Web/MatrixUtils.Web.csproj
@@ -17,24 +17,24 @@ <!-- Explicitly disable all the unused runtime things trimming would have removed anyways --> <!-- https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options --> - <PropertyGroup> - <AutoreleasePoolSupport>false</AutoreleasePoolSupport> <!-- Browser != MacOS --> - <MetadataUpdaterSupport>false</MetadataUpdaterSupport> <!-- Unreliable --> - <DebuggerSupport>false</DebuggerSupport> <!-- Unreliable --> - <InvariantGlobalization>true</InvariantGlobalization> <!-- invariant globalization is fine --> - <!-- unused features --> - <EventSourceSupport>false</EventSourceSupport> - <EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization> - <HttpActivityPropagationSupport>false</HttpActivityPropagationSupport> - <EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding> - <MetricsSupport>false</MetricsSupport> - <UseNativeHttpHandler>false</UseNativeHttpHandler> - <XmlResolverIsNetworkingEnabledByDefault>false</XmlResolverIsNetworkingEnabledByDefault> - <BuiltInComInteropSupport>false</BuiltInComInteropSupport> - <CustomResourceTypesSupport>false</CustomResourceTypesSupport> - <EnableCppCLIHostActivation>false</EnableCppCLIHostActivation> - <StartupHookSupport>false</StartupHookSupport> - </PropertyGroup> +<!-- <PropertyGroup>--> +<!-- <AutoreleasePoolSupport>false</AutoreleasePoolSupport> &lt;!&ndash; Browser != MacOS &ndash;&gt;--> +<!-- <MetadataUpdaterSupport>false</MetadataUpdaterSupport> &lt;!&ndash; Unreliable &ndash;&gt;--> +<!-- <DebuggerSupport>false</DebuggerSupport> &lt;!&ndash; Unreliable &ndash;&gt;--> +<!-- <InvariantGlobalization>true</InvariantGlobalization> &lt;!&ndash; invariant globalization is fine &ndash;&gt;--> +<!-- &lt;!&ndash; unused features &ndash;&gt;--> +<!-- <EventSourceSupport>false</EventSourceSupport>--> +<!-- <EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>--> +<!-- <HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>--> +<!-- <EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>--> +<!-- <MetricsSupport>false</MetricsSupport>--> +<!-- <UseNativeHttpHandler>false</UseNativeHttpHandler>--> +<!-- <XmlResolverIsNetworkingEnabledByDefault>false</XmlResolverIsNetworkingEnabledByDefault>--> +<!-- <BuiltInComInteropSupport>false</BuiltInComInteropSupport>--> +<!-- <CustomResourceTypesSupport>false</CustomResourceTypesSupport>--> +<!-- <EnableCppCLIHostActivation>false</EnableCppCLIHostActivation>--> +<!-- <StartupHookSupport>false</StartupHookSupport>--> +<!-- </PropertyGroup>--> <ItemGroup> <PackageReference Include="Blazored.LocalStorage" Version="4.5.0"/> @@ -42,7 +42,7 @@ <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.1" PrivateAssets="all" /> <PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="9.0.1" /> - <PackageReference Include="SpawnDev.BlazorJS.WebWorkers" Version="2.5.36" /> + <PackageReference Include="SpawnDev.BlazorJS.WebWorkers" Version="2.5.39" /> </ItemGroup> <ItemGroup> diff --git a/MatrixUtils.Web/Pages/Index.razor b/MatrixUtils.Web/Pages/Index.razor
index 8847467..b9d3233 100644 --- a/MatrixUtils.Web/Pages/Index.razor +++ b/MatrixUtils.Web/Pages/Index.razor
@@ -25,8 +25,9 @@ Small collection of tools to do not-so-everyday things. var auth = session.UserAuth; <tr class="user-entry"> <td> - @if (!string.IsNullOrWhiteSpace(@session.UserInfo.AvatarUrl)) { - <MxcAvatar Homeserver="session.Homeserver" MxcUri="@session.UserInfo.AvatarUrl" Circular="true" Size="4" SizeUnit="em"/> + @if (!string.IsNullOrWhiteSpace(@session.UserInfo?.AvatarUrl)) { + // Console.WriteLine($"Rendering {session.UserInfo.AvatarUrl} with homeserver {session.Homeserver}"); + <MxcAvatar Homeserver="@session.Homeserver" MxcUri="@session.UserInfo.AvatarUrl" Circular="true" Size="4" SizeUnit="em"/> } else { <img class="avatar" src="@_identiconGenerator.GenerateAsDataUri(session.Homeserver.WhoAmI.UserId)"/> diff --git a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientRoomList.razor b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientRoomList.razor
index b370080..8831dd1 100644 --- a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientRoomList.razor +++ b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientRoomList.razor
@@ -10,6 +10,6 @@ @code { [Parameter] - public ClientContext Data { get; set; } = null!; + public ClientContext Data { get; set; } } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientStatusList.razor b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientStatusList.razor
index c680c13..60f850d 100644 --- a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientStatusList.razor +++ b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/ClientStatusList.razor
@@ -10,7 +10,7 @@ @code { [Parameter] - public ObservableCollection<ClientContext> Data { get; set; } = null!; + public ObservableCollection<ClientContext> Data { get; set; } protected override void OnInitialized() { Data.CollectionChanged += (_, e) => { diff --git a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/MatrixClient.razor b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/MatrixClient.razor
index 67dcae5..6a930b1 100644 --- a/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/MatrixClient.razor +++ b/MatrixUtils.Web/Pages/Labs/Client/ClientComponents/MatrixClient.razor
@@ -25,6 +25,6 @@ @code { [Parameter] - public Index.ClientContext Data { get; set; } = null!; + public Index.ClientContext Data { get; set; } } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/MainTabComponents/MainTabSpaceItem.razor b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/MainTabComponents/MainTabSpaceItem.razor
index 596d63d..ba994d1 100644 --- a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/MainTabComponents/MainTabSpaceItem.razor +++ b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/MainTabComponents/MainTabSpaceItem.razor
@@ -1,14 +1,14 @@ @using MatrixUtils.Abstractions -<div class="spaceListItem" style="@(SelectedSpace == Space ? "background-color: #FFFFFF33;" : "")" onclick="@SelectSpace"> +<div class="spaceListItem" style="@(SelectedSpace == Space ? "background-color: #FFFFFF33;" : "")" @onclick="@SelectSpace"> <div class="spaceListItemContainer"> @if (IsSpaceOpened()) { - <span onclick="@ToggleSpace">▼ </span> + <span @onclick="@ToggleSpace">▼ </span> } else { - <span onclick="@ToggleSpace">▶ </span> + <span @onclick="@ToggleSpace">▶ </span> } - <MxcImage Circular="true" Height="32" Width="32" MxcUri="@Space.RoomIcon"></MxcImage> + <MxcImage Homeserver="@Homeserver" Circular="true" Height="32" Width="32" Uri="@Space.RoomIcon"></MxcImage> <span class="spaceNameEllipsis">@Space.RoomName</span> </div> @if (IsSpaceOpened()) { @@ -30,6 +30,9 @@ [Parameter] public List<RoomInfo> OpenedSpaces { get; set; } + [Parameter] + public AuthenticatedHomeserverGeneric Homeserver { get; set; } + protected override Task OnInitializedAsync() { Space.PropertyChanged += (sender, args) => { StateHasChanged(); }; return base.OnInitializedAsync(); diff --git a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2ByRoomTypeTab.razor b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2ByRoomTypeTab.razor
index f4cf849..79f931b 100644 --- a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2ByRoomTypeTab.razor +++ b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2ByRoomTypeTab.razor
@@ -22,7 +22,7 @@ @code { [CascadingParameter] - public Index2.RoomListViewData Data { get; set; } = null!; + public Index2.RoomListViewData Data { get; set; } protected override async Task OnInitializedAsync() { Data.Rooms.CollectionChanged += (sender, args) => { diff --git a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2DMsTab.razor b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2DMsTab.razor
index f4cf849..79f931b 100644 --- a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2DMsTab.razor +++ b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2DMsTab.razor
@@ -22,7 +22,7 @@ @code { [CascadingParameter] - public Index2.RoomListViewData Data { get; set; } = null!; + public Index2.RoomListViewData Data { get; set; } protected override async Task OnInitializedAsync() { Data.Rooms.CollectionChanged += (sender, args) => { diff --git a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2MainTab.razor b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2MainTab.razor
index 6bf542f..99b031a 100644 --- a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2MainTab.razor +++ b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2MainTab.razor
@@ -47,7 +47,7 @@ @code { [CascadingParameter] - public Index2.RoomListViewData Data { get; set; } = null!; + public Index2.RoomListViewData Data { get; set; } protected override async Task OnInitializedAsync() { Data.Rooms.CollectionChanged += (sender, args) => { diff --git a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2SyncContainer.razor b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2SyncContainer.razor
index ae57521..33c310a 100644 --- a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2SyncContainer.razor +++ b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2Components/RoomsIndex2SyncContainer.razor
@@ -16,7 +16,7 @@ @code { [Parameter] - public Index2.RoomListViewData Data { get; set; } = null!; + public Index2.RoomListViewData Data { get; set; } private SyncHelper syncHelper; @@ -113,7 +113,7 @@ statusd.Status = $"{roomId} already known with {room.StateEvents?.Count ?? 0} state events"; } else { - statusd.Status = $"Eencountered new room {roomId}!"; + statusd.Status = $"Encountered new room {roomId}!"; room = new RoomInfo(Data.Homeserver!.GetRoom(roomId), roomData.State?.Events); Data.Rooms.Add(room); } diff --git a/MatrixUtils.Web/Pages/Rooms/Index.razor b/MatrixUtils.Web/Pages/Rooms/Index.razor
index 5dd8189..45219c7 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index.razor +++ b/MatrixUtils.Web/Pages/Rooms/Index.razor
@@ -13,9 +13,7 @@ <p>@Status2</p> <LinkButton href="/Rooms/Create">Create new room</LinkButton> -<CascadingValue TValue="AuthenticatedHomeserverGeneric" Value="Homeserver"> - <RoomList Rooms="Rooms" GlobalProfile="@GlobalProfile" @bind-StillFetching="RenderContents"></RoomList> -</CascadingValue> +<RoomList Rooms="Rooms" GlobalProfile="@GlobalProfile" @bind-StillFetching="RenderContents" Homeserver="@Homeserver"></RoomList> @code { @@ -122,7 +120,7 @@ try { while (queue.Count == 0) { Console.WriteLine("Queue is empty, waiting..."); - await Task.Delay(isInitialSync ? 100 : 2500); + await Task.Delay(isInitialSync ? 1000 : 2500); } Console.WriteLine($"Queue no longer empty after {renderTimeSw.Elapsed}!"); @@ -131,15 +129,15 @@ isInitialSync = false; while (maxUpdates-- > 0 && queue.TryDequeue(out var queueEntry)) { var (roomId, roomData) = queueEntry; - Console.WriteLine($"Dequeued room {roomId}"); + // Console.WriteLine($"Dequeued room {roomId}"); RoomInfo room; if (Rooms.Any(x => x.Room.RoomId == roomId)) { room = Rooms.First(x => x.Room.RoomId == roomId); - Console.WriteLine($"QueueWorker: {roomId} already known with {room.StateEvents?.Count ?? 0} state events"); + // Console.WriteLine($"QueueWorker: {roomId} already known with {room.StateEvents?.Count ?? 0} state events"); } else { - Console.WriteLine($"QueueWorker: encountered new room {roomId}!"); + // Console.WriteLine($"QueueWorker: encountered new room {roomId}!"); room = new RoomInfo(Homeserver.GetRoom(roomId), roomData.State?.Events); Rooms.Add(room); } @@ -155,6 +153,11 @@ Console.WriteLine($"QueueWorker: could not merge state for {room.Room.RoomId} as new data contains no state events!"); } + if (maxUpdates % 100 == 0) { + Console.WriteLine($"QueueWorker: {queue.Count} entries left in queue, {maxUpdates} maxUpdates left, RenderContents: {RenderContents}"); + StateHasChanged(); + await Task.Yield(); + } // await Task.Delay(100); } @@ -225,9 +228,10 @@ Rooms.Remove(Rooms.First(x => x.Room.RoomId == leftRoom.Key)); Status = $"Got {Rooms.Count} rooms so far! {queue.Count} entries in processing queue... " + - $"{sync?.Rooms?.Join?.Count ?? 0} new updates!"; + $"{sync.Rooms?.Join?.Count ?? 0} new updates!"; - Status2 = $"Next batch: {sync.NextBatch}"; + Status2 = $"Next batch: {sync?.NextBatch}"; + await Task.Yield(); } } diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyList.razor b/MatrixUtils.Web/Pages/Rooms/PolicyList.razor
index 94113dd..3d78f4a 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyList.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyList.razor
@@ -171,7 +171,7 @@ else { private bool Loading { get; set; } = true; [Parameter] - public string RoomId { get; set; } = null!; + public string RoomId { get; set; } private bool _enableAvatars; private StateEventResponse? _currentlyEditingEvent; diff --git a/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor b/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor
index 50f304a..664551a 100644 --- a/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor +++ b/MatrixUtils.Web/Pages/Rooms/PolicyList2.razor
@@ -141,7 +141,7 @@ else { private bool Loading { get; set; } = true; [Parameter] - public string RoomId { get; set; } = null!; + public string RoomId { get; set; } private bool _enableAvatars; private StateEventResponse? _currentlyEditingEvent; diff --git a/MatrixUtils.Web/Pages/StreamTest.razor b/MatrixUtils.Web/Pages/StreamTest.razor
index 4cec354..aae1f17 100644 --- a/MatrixUtils.Web/Pages/StreamTest.razor +++ b/MatrixUtils.Web/Pages/StreamTest.razor
@@ -5,7 +5,7 @@ <PageTitle>StreamText</PageTitle> @if (Homeserver is not null) { - <p>Got homeserver @Homeserver.BaseUrl</p> + <p>Got homeserver @Homeserver.ServerName</p> @* <img src="@ResolvedUri" @ref="imgElement"/> *@ @* <StreamedImage Stream="@Stream"/> *@ diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/InviteCounter.razor b/MatrixUtils.Web/Pages/Tools/Moderation/InviteCounter.razor
index ea47237..cb1328c 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/InviteCounter.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/InviteCounter.razor
@@ -1,6 +1,8 @@ @page "/Tools/Moderation/InviteCounter" @using System.Collections.ObjectModel +@using ArcaneLibs.Extensions @using LibMatrix.EventTypes.Spec.State.RoomInfo +@using LibMatrix.Filters <h3>Invite counter</h3> <hr/> @@ -13,7 +15,7 @@ <details> <summary>Results</summary> - @foreach (var (userId, events) in invites.OrderByDescending(x=>x.Value).ToList()) { + @foreach (var (userId, events) in invites.OrderByDescending(x => x.Value).ToList()) { <p>@userId: @events</p> } </details> @@ -27,16 +29,15 @@ private ObservableCollection<string> log { get; set; } = new(); private Dictionary<string, int> invites { get; set; } = new(); private AuthenticatedHomeserverGeneric hs { get; set; } - + [Parameter, SupplyParameterFromQuery(Name = "room")] public string roomId { get; set; } - protected override async Task OnInitializedAsync() { log.CollectionChanged += (sender, args) => StateHasChanged(); hs = await RmuStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - + StateHasChanged(); Console.WriteLine("Rerendered!"); await base.OnInitializedAsync(); @@ -44,22 +45,21 @@ private async Task<string> Execute() { var room = hs.GetRoom(roomId); - var events = room.GetManyMessagesAsync(limit: int.MaxValue); + var filter = new SyncFilter.EventFilter() { Types = [RoomMemberEventContent.EventId] }; + var events = room.GetManyMessagesAsync(limit: int.MaxValue, filter: filter.ToJson(ignoreNull: true, indent: false)); await foreach (var resp in events) { var all = resp.State.Concat(resp.Chunk); foreach (var evt in all) { - if(evt.Type != RoomMemberEventContent.EventId) continue; + if (evt.Type != RoomMemberEventContent.EventId) continue; var content = evt.TypedContent as RoomMemberEventContent; - if(content.Membership != "invite") continue; - if(!invites.ContainsKey(evt.Sender)) invites[evt.Sender] = 0; - invites[evt.Sender]++; + if (content?.Membership != "invite") continue; + invites.TryAdd(evt.Sender!, 0); + invites[evt.Sender!]++; } log.Add($"{resp.State.Count} state, {resp.Chunk.Count} timeline"); } - - - + StateHasChanged(); return ""; diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor b/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor
index 6b5b5e4..2549c12 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/MembershipHistory.razor
@@ -2,8 +2,10 @@ @using System.Collections.Frozen @using System.Collections.ObjectModel @using System.Diagnostics +@using ArcaneLibs.Extensions @using LibMatrix @using LibMatrix.EventTypes.Spec.State.RoomInfo +@using LibMatrix.Filters @{ var sw = Stopwatch.StartNew(); Console.WriteLine("Start render"); @@ -397,7 +399,7 @@ private ObservableCollection<string> Log { get; set; } = new(); private List<StateEventResponse> Memberships { get; set; } = []; - private AuthenticatedHomeserverGeneric Homeserver { get; set; } = null!; + private AuthenticatedHomeserverGeneric Homeserver { get; set; } [Parameter, SupplyParameterFromQuery(Name = "room")] public string RoomId { get; set; } = ""; @@ -417,7 +419,8 @@ private async Task Execute() { Memberships.Clear(); var room = Homeserver.GetRoom(RoomId); - var events = room.GetManyMessagesAsync(limit: int.MaxValue, chunkSize: 5000); + var filter = new SyncFilter.EventFilter() { Types = [RoomMemberEventContent.EventId] }; + var events = room.GetManyMessagesAsync(limit: int.MaxValue, filter: filter.ToJson(ignoreNull: true, indent: false)); await foreach (var resp in events) { var all = resp.State.Concat(resp.Chunk); Memberships.AddRange(all.Where(x => x.Type == RoomMemberEventContent.EventId)); diff --git a/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor b/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor
index 0d622cc..73818c6 100644 --- a/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor +++ b/MatrixUtils.Web/Pages/Tools/Moderation/UserTrace.razor
@@ -181,6 +181,9 @@ { Membership: "leave", Reason: not null } => state.Sender == state.StateKey ? $"Left at {time} with reason {membership.Reason}" : $"Kicked by {state.Sender} at {time} for {membership.Reason}", { Membership: "ban", Reason: null } => $"Banned by {state.Sender} at {time}", { Membership: "ban", Reason: not null } => $"Banned by {state.Sender} at {time} for {membership.Reason}", + { Membership: "knock", Reason: null } => $"Knocked at {time}", + { Membership: "knock", Reason: not null } => $"Knocked at {time} for {membership.Reason}", + _ => $"Unknown membership {membership.Membership}, sent at {time} by {state.Sender} for {membership.Reason}" }; } diff --git a/MatrixUtils.Web/Pages/User/Profile.razor b/MatrixUtils.Web/Pages/User/Profile.razor
index d0af2c8..b6ac1d4 100644 --- a/MatrixUtils.Web/Pages/User/Profile.razor +++ b/MatrixUtils.Web/Pages/User/Profile.razor
@@ -10,7 +10,7 @@ <h4>Profile</h4> <hr/> <div> - <MxcAvatar MxcUri="@NewProfile.AvatarUrl" Circular="true" Size="96"/> + <MxcAvatar Homeserver="@Homeserver" MxcUri="@NewProfile.AvatarUrl" Circular="true" Size="96"/> <div style="display: inline-block; vertical-align: middle;"> <span>Display name: </span><FancyTextBox @bind-Value="@NewProfile.DisplayName"></FancyTextBox><br/> <span>Avatar URL: </span><FancyTextBox @bind-Value="@NewProfile.AvatarUrl"></FancyTextBox> @@ -39,7 +39,7 @@ </summary> @if (room.OwnMembership is not null) { @* <img src="@Homeserver.ResolveMediaUri(room.OwnMembership.AvatarUrl)" style="width: 96px; height: 96px; border-radius: 50%; object-fit: cover;"/> *@ - <MxcAvatar MxcUri="@room.OwnMembership.AvatarUrl" Circular="true" Size="96"/> + <MxcAvatar Homeserver="@Homeserver" MxcUri="@room.OwnMembership.AvatarUrl" Circular="true" Size="96"/> <div style="display: inline-block; vertical-align: middle;"> <span>Display name: </span><FancyTextBox BackgroundColor="@(room.OwnMembership.DisplayName == OldProfile.DisplayName ? "" : "#ffff0033")" @bind-Value="@room.OwnMembership.DisplayName"></FancyTextBox><br/> <span>Avatar URL: </span><FancyTextBox BackgroundColor="@(room.OwnMembership.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")" @bind-Value="@room.OwnMembership.AvatarUrl"></FancyTextBox> diff --git a/MatrixUtils.Web/Shared/InlineUserItem.razor b/MatrixUtils.Web/Shared/InlineUserItem.razor
index 50fa9e1..eaf7a92 100644 --- a/MatrixUtils.Web/Shared/InlineUserItem.razor +++ b/MatrixUtils.Web/Shared/InlineUserItem.razor
@@ -39,7 +39,6 @@ protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); - Homeserver ??= await RmuStorage.GetCurrentSessionOrNavigate(); if(Homeserver is null) return; await _semaphoreSlim.WaitAsync(); diff --git a/MatrixUtils.Web/Shared/MxcAvatar.razor b/MatrixUtils.Web/Shared/MxcAvatar.razor
index 02aff72..822894a 100644 --- a/MatrixUtils.Web/Shared/MxcAvatar.razor +++ b/MatrixUtils.Web/Shared/MxcAvatar.razor
@@ -1,17 +1,16 @@ -<StreamedImage Stream="@_stream" style="@StyleString"/> +<MxcImage Homeserver="@Homeserver" Uri="@MxcUri" style="@StyleString"/> @code { - private string _mxcUri; private string _style; - private Stream _stream; - + [Parameter] - public string MxcUri { - get => _mxcUri ?? ""; + public string? MxcUri { + get; set { - if(_mxcUri == value) return; - _mxcUri = value; - UriHasChanged(value); + if(field == value) return; + field = value; + // UriHasChanged(value); + StateHasChanged(); } } @@ -25,31 +24,26 @@ public string SizeUnit { get; set; } = "px"; [Parameter] - public AuthenticatedHomeserverGeneric? Homeserver { get; set; } + public required AuthenticatedHomeserverGeneric Homeserver { get; set; } private string StyleString => $"{(Circular ? "border-radius: 50%;" : "")} width: {Size}{SizeUnit}; height: {Size}{SizeUnit}; object-fit: cover;"; private static readonly string Prefix = "mxc://"; private static readonly int PrefixLength = Prefix.Length; - private async Task UriHasChanged(string value) { - if (!value.StartsWith(Prefix)) { - // Console.WriteLine($"UriHasChanged: {value} does not start with {Prefix}, passing as resolved URI!!!"); - // ResolvedUri = value; - return; - } - - if (Homeserver is null) { - Console.WriteLine("Homeserver is required for MxcAvatar"); - return; - } - - var uri = value[PrefixLength..].Split('/'); - // Console.WriteLine($"UriHasChanged: {value} {uri[0]}"); - var url = $"/_matrix/media/v3/download/{uri[0]}/{uri[1]}"; - Console.WriteLine($"ResolvedUri: {url}"); - _stream = await Homeserver.ClientHttpClient.GetStreamAsync(url); - StateHasChanged(); - } + // private async Task UriHasChanged(string? value) { + // if (string.IsNullOrWhiteSpace(value) || !value.StartsWith(Prefix)) { + // Console.WriteLine($"[MxcAvatar] UriHasChanged: {value} does not start with {Prefix}!"); + // return; + // } + // + // if (Homeserver is null) { + // Console.WriteLine($"[MxcAvatar] Homeserver is required for MxcAvatar! URI: {MxcUri}, Homeserver: {Homeserver?.ToString() ?? "null"}"); + // return; + // } + // + // Console.WriteLine($"[MxcAvatar] Homeserver: {Homeserver}"); + // StateHasChanged(); + // } } \ No newline at end of file diff --git a/MatrixUtils.Web/Shared/MxcImage.razor b/MatrixUtils.Web/Shared/MxcImage.razor
index e7cb2e0..26609ee 100644 --- a/MatrixUtils.Web/Shared/MxcImage.razor +++ b/MatrixUtils.Web/Shared/MxcImage.razor
@@ -1,69 +1,69 @@ -<img src="@ResolvedUri" style="@StyleString"/> -@code { - private string _mxcUri; - private string _style; - private string _resolvedUri; +<AuthorizedImage src="@ResolvedUrl" AccessToken="@Homeserver?.AccessToken" style="@StyleString"/> +@code { [Parameter] - public string MxcUri { - get => _mxcUri ?? ""; + public string? Uri { + get; set { - Console.WriteLine($"New MXC uri: {value}"); - _mxcUri = value; + // Console.WriteLine($"New MXC uri: {value}"); + if (field == value) return; + field = value; UriHasChanged(value); } } + [Parameter] public bool Circular { get; set; } - + [Parameter] public int? Width { get; set; } - + [Parameter] public int? Height { get; set; } - + [Parameter] - public string Style { - get => _style; + public string? Style { + get; set { - _style = value; + field = value; StateHasChanged(); } } - - [CascadingParameter, Parameter] - public RemoteHomeserver? Homeserver { get; set; } - private string ResolvedUri { - get => _resolvedUri; + [Parameter] + public required AuthenticatedHomeserverGeneric Homeserver { get; set; } + + private string? ResolvedUrl { + get; set { - _resolvedUri = value; + field = value; StateHasChanged(); } } private string StyleString => $"{Style} {(Circular ? "border-radius: 50%;" : "")} {(Width.HasValue ? $"width: {Width}px;" : "")} {(Height.HasValue ? $"height: {Height}px;" : "")} object-fit: cover;"; - - private static readonly string Prefix = "mxc://"; - private static readonly int PrefixLength = Prefix.Length; - private async Task UriHasChanged(string value) { - // if (!value.StartsWith(Prefix)) { - // Console.WriteLine($"UriHasChanged: {value} does not start with {Prefix}, passing as resolved URI!!!"); - // ResolvedUri = value; - // return; - // } - // var uri = value[PrefixLength..].Split('/'); - // Console.WriteLine($"UriHasChanged: {value} {uri[0]}"); - // if (Homeserver is null) { - // Console.WriteLine($"Homeserver is null, creating new remotehomeserver for {uri[0]}"); - // Homeserver = await hsProvider.GetRemoteHomeserver(uri[0]); - // } - // ResolvedUri = Homeserver.ResolveMediaUri(value); - // Console.WriteLine($"ResolvedUri: {ResolvedUri}"); - } + // private static readonly string Prefix = "mxc://"; + // private static readonly int PrefixLength = Prefix.Length; + + private async Task UriHasChanged(string? value) { + try { + if (string.IsNullOrWhiteSpace(value)) { + ResolvedUrl = null; + return; + } + + if (Homeserver is null) { + Console.WriteLine($"Homeserver is required for MxcImage! Uri: {value}, Homeserver: {Homeserver?.ToString() ?? "null"}"); + return; + } - // [Parameter] - // public string Class { get; set; } + ResolvedUrl = await Homeserver.GetMediaUrlAsync(value); + // Console.WriteLine($"[MxcImage] Resolved URL: {ResolvedUrl}"); + StateHasChanged(); + } catch (Exception e) { + await Console.Error.WriteLineAsync($"Error resolving media URL: {e}"); + } + } } \ No newline at end of file diff --git a/MatrixUtils.Web/Shared/RoomList.razor b/MatrixUtils.Web/Shared/RoomList.razor
index 42c5a9f..ba9cd69 100644 --- a/MatrixUtils.Web/Shared/RoomList.razor +++ b/MatrixUtils.Web/Shared/RoomList.razor
@@ -10,7 +10,7 @@ } else { @foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) { - <RoomListCategory Category="@category" GlobalProfile="@GlobalProfile"></RoomListCategory> + <RoomListCategory Category="@category" GlobalProfile="@GlobalProfile" Homeserver="@Homeserver"></RoomListCategory> } } @@ -35,6 +35,9 @@ else { } [Parameter] + public AuthenticatedHomeserverGeneric? Homeserver { get; set; } + + [Parameter] public UserProfileResponse? GlobalProfile { get; set; } [Parameter] diff --git a/MatrixUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
index 555b1f1..1ab0a1a 100644 --- a/MatrixUtils.Web/Shared/RoomListComponents/RoomListCategory.razor +++ b/MatrixUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
@@ -6,7 +6,7 @@ <summary>@RoomType (@Rooms.Count)</summary> @foreach (var room in Rooms) { <div class="room-list-item"> - <RoomListItem RoomInfo="@room" ShowOwnProfile="@(RoomType == "Room")"></RoomListItem> + <RoomListItem RoomInfo="@room" ShowOwnProfile="@(RoomType == "Room")" Homeserver="@Homeserver"/> @* @if (RoomVersionDangerLevel(room) != 0 && *@ @* (room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.power_levels")?.TypedContent is RoomPowerLevelEventContent powerLevels && powerLevels.UserHasPermission(Homeserver.UserId, "m.room.tombstone"))) { *@ @* <MatrixUtils.Web.Shared.SimpleComponents.LinkButton Color="@(RoomVersionDangerLevel(room) == 2 ? "#ff0000" : "#ff8800")" href="@($"/Rooms/Create?Import={room.Room.RoomId}")">Upgrade room</MatrixUtils.Web.Shared.SimpleComponents.LinkButton> *@ @@ -14,10 +14,11 @@ <LinkButton href="@($"/Rooms/{room.Room.RoomId}/Timeline")">View timeline</LinkButton> <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</LinkButton> <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/Edit")">Edit state</LinkButton> + <LinkButton href="@($"/Rooms/{room.Room.RoomId}/Upgrade")" Color="#888800">Upgrade/replace room</LinkButton> <LinkButton href="@($"/Tools/LeaveRoom?roomId={room.Room.RoomId}")" Color="#FF0000">Leave room</LinkButton> @if (room.CreationEventContent?.Type == "m.space") { - <RoomListSpace Space="@room"></RoomListSpace> + <RoomListSpace Space="@room" Homeserver="@Homeserver"/> } else if (room.CreationEventContent?.Type == "support.feline.policy.lists.msc.v1" || RoomType == "org.matrix.mjolnir.policy") { <LinkButton href="@($"/Rooms/{room.Room.RoomId}/Policies")">Manage policies</LinkButton> @@ -35,9 +36,9 @@ [Parameter] public UserProfileResponse? GlobalProfile { get; set; } - [CascadingParameter] - public AuthenticatedHomeserverGeneric Homeserver { get; set; } = null!; - + [Parameter] + public AuthenticatedHomeserverGeneric? Homeserver { get; set; } + private string RoomType => Category.Key; private List<RoomInfo> Rooms => Category.Value; diff --git a/MatrixUtils.Web/Shared/RoomListComponents/RoomListSpace.razor b/MatrixUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
index 11f9040..27f0499 100644 --- a/MatrixUtils.Web/Shared/RoomListComponents/RoomListSpace.razor +++ b/MatrixUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
@@ -35,15 +35,18 @@ set => _breadcrumbs = value; } + [Parameter] + public required AuthenticatedHomeserverGeneric Homeserver { get; set; } + private ObservableCollection<RoomInfo> Children { get; set; } = new(); private Collection<RoomInfo> Unjoined { get; set; } = new(); protected override async Task OnInitializedAsync() { if (Breadcrumbs == null) throw new ArgumentNullException(nameof(Breadcrumbs)); + if (Homeserver is null) throw new ArgumentNullException(nameof(Homeserver)); await Task.Delay(Random.Shared.Next(1000, 10000)); var rooms = Space.Room.AsSpace.GetChildrenAsync(); - var hs = await RmuStorage.GetCurrentSessionOrNavigate(); - var joinedRooms = await hs.GetJoinedRooms(); + var joinedRooms = await Homeserver.GetJoinedRooms(); await foreach (var room in rooms) { if (Breadcrumbs.Contains(room.RoomId)) continue; var roomInfo = KnownRooms.FirstOrDefault(x => x.Room.RoomId == room.RoomId); @@ -51,10 +54,12 @@ roomInfo = new RoomInfo(room); KnownRooms.Add(roomInfo); } - if(joinedRooms.Any(x=>x.RoomId == room.RoomId)) + + if (joinedRooms.Any(x => x.RoomId == room.RoomId)) Children.Add(roomInfo); else Unjoined.Add(roomInfo); } + await base.OnInitializedAsync(); } diff --git a/MatrixUtils.Web/Shared/RoomListItem.razor b/MatrixUtils.Web/Shared/RoomListItem.razor
index d75d159..46daaa2 100644 --- a/MatrixUtils.Web/Shared/RoomListItem.razor +++ b/MatrixUtils.Web/Shared/RoomListItem.razor
@@ -1,3 +1,4 @@ +@using ArcaneLibs @using LibMatrix @using LibMatrix.EventTypes.Spec.State.RoomInfo @using LibMatrix.Responses @@ -6,16 +7,20 @@ @if (RoomInfo is not null) { <div class="roomListItem @(HasDangerousRoomVersion ? "dangerousRoomVersion" : HasOldRoomVersion ? "oldRoomVersion" : "")" id="@RoomInfo.Room.RoomId"> @if (OwnMemberState != null) { - @* Class="@("avatar32" + (OwnMemberState?.AvatarUrl != GlobalProfile?.AvatarUrl ? " highlightChange" : "") + (ChildContent is not null ? " vcenter" : ""))" *@ - @* <MxcImage Homeserver="hs" Circular="true" Height="32" Width="32" MxcUri="@(OwnMemberState.AvatarUrl ?? GlobalProfile.AvatarUrl)"/> *@ - <MxcAvatar Homeserver="Homeserver" Circular="true" Size="32" MxcUri="@(OwnMemberState.AvatarUrl ?? GlobalProfile.AvatarUrl)"/> + <MxcAvatar Homeserver="@Homeserver" Circular="true" Size="32" MxcUri="@(OwnMemberState.AvatarUrl ?? GlobalProfile.AvatarUrl)"/> <span class="centerVertical border75 @(OwnMemberState?.AvatarUrl != GlobalProfile?.AvatarUrl ? "highlightChange" : "")"> @(OwnMemberState?.DisplayName ?? GlobalProfile?.DisplayName ?? "Loading...") </span> <span class="centerVertical noLeftPadding">-></span> } @* <MxcImage Circular="true" Height="32" Width="32" MxcUri="@RoomInfo.RoomIcon" Style="@(ChildContent is not null ? "vertical-align: middle;" : "")"/> *@ - <MxcAvatar Homeserver="Homeserver" Circular="true" Size="32" MxcUri="@RoomInfo.RoomIcon"/> + + @if (!string.IsNullOrWhiteSpace(RoomInfo.RoomIcon)) { + <MxcAvatar Homeserver="@Homeserver" Circular="true" Size="32" MxcUri="@RoomInfo.RoomIcon"/> + } + else { + <img src="@Identicon" width="32" height="32" style="border-radius: 50%;"/> + } <div class="inlineBlock"> <span class="centerVertical">@RoomInfo.RoomName</span> @if (ChildContent is not null) { @@ -68,6 +73,10 @@ else { private bool HasOldRoomVersion { get; set; } = false; private bool HasDangerousRoomVersion { get; set; } = false; + private string Identicon { get; set; } + + private static SvgIdenticonGenerator _identiconGenerator = new SvgIdenticonGenerator(); + private static SemaphoreSlim _semaphoreSlim = new(8); private RoomInfo? _roomInfo; private bool _loadData = false; @@ -75,6 +84,9 @@ else { private bool _hooked; private async Task RoomInfoChanged() { + if (RoomInfo is null) return; + Identicon = _identiconGenerator.GenerateAsDataUri(RoomInfo.Room.RoomId); + RoomInfo.PropertyChanged += async (_, a) => { if (a.PropertyName == nameof(RoomInfo.CreationEventContent)) { await CheckRoomVersion(); diff --git a/MatrixUtils.Web/Shared/UserListItem.razor b/MatrixUtils.Web/Shared/UserListItem.razor
index cf7f24d..8ce2868 100644 --- a/MatrixUtils.Web/Shared/UserListItem.razor +++ b/MatrixUtils.Web/Shared/UserListItem.razor
@@ -23,13 +23,14 @@ [Parameter] public string UserId { get; set; } - private AuthenticatedHomeserverGeneric _homeserver = null!; + [Parameter] + public AuthenticatedHomeserverGeneric _homeserver { get; set; } private SvgIdenticonGenerator _identiconGenerator = new(); protected override async Task OnInitializedAsync() { - _homeserver = await RmuStorage.GetCurrentSessionOrNavigate(); - if (_homeserver is null) return; + // _homeserver = await RmuStorage.GetCurrentSessionOrNavigate(); + // if (_homeserver is null) return; if (User == null) { if (UserId == null) {