From 257019113200d714d86d22ccab6c18b37cd28283 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 3 Jul 2023 00:43:34 +0200 Subject: Local changes --- MatrixRoomUtils.Web/Shared/RoomList.razor | 14 +++----------- .../Shared/RoomListComponents/RoomListCategory.razor | 17 ++++++++++++++--- MatrixRoomUtils.Web/Shared/RoomListItem.razor | 4 ++-- .../Shared/SimpleComponents/LinkButton.razor | 7 +++++-- 4 files changed, 24 insertions(+), 18 deletions(-) (limited to 'MatrixRoomUtils.Web/Shared') diff --git a/MatrixRoomUtils.Web/Shared/RoomList.razor b/MatrixRoomUtils.Web/Shared/RoomList.razor index db2d059..fadec1c 100644 --- a/MatrixRoomUtils.Web/Shared/RoomList.razor +++ b/MatrixRoomUtils.Web/Shared/RoomList.razor @@ -2,9 +2,8 @@ @using MatrixRoomUtils.Core.StateEventTypes @using MatrixRoomUtils.Core.StateEventTypes.Common @using MatrixRoomUtils.Core.StateEventTypes.Spec -

@Rooms.Count rooms total, @RoomsWithTypes.Sum(x=>x.Value.Count) fetched so far...

@if(Rooms.Count != RoomsWithTypes.Sum(x=>x.Value.Count)) { -

Fetching more rooms...

+

Fetching room details... @RoomsWithTypes.Sum(x=>x.Value.Count) out of @Rooms.Count done!

@foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) {

@category.Key (@category.Value.Count)

} @@ -28,7 +27,7 @@ else { GlobalProfile ??= await (await MRUStorage.GetCurrentSession())!.GetProfile((await MRUStorage.GetCurrentSession())!.WhoAmI.UserId); if (RoomsWithTypes.Any()) return; - var tasks = Rooms.Select(AddRoom); + var tasks = Rooms.Select(ProcessRoom); await Task.WhenAll(tasks); await base.OnInitializedAsync(); @@ -44,7 +43,7 @@ else { private static SemaphoreSlim _semaphoreSlim = new(8, 8); - private async Task AddRoom(RoomInfo room) { + private async Task ProcessRoom(RoomInfo room) { await _semaphoreSlim.WaitAsync(); string roomType; try { @@ -56,11 +55,6 @@ else { if(mjolnirData?.RawContent?.ToJson(ignoreNull: true) is not null and not "{}") roomType = "Legacy policy room"; } - //prefetch some stuff - await Task.WhenAll( - room.GetStateEvent("m.room.name"), - room.GetStateEvent("m.room.name") - ); } catch (MatrixException e) { roomType = $"Error: {e.ErrorCode}"; @@ -71,9 +65,7 @@ else { } RoomsWithTypes[roomType].Add(room); - // if (RoomsWithTypes[roomType].Count % 10 == 0) StateHasChanged(); - // await Task.Delay(100); _semaphoreSlim.Release(); } diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor index 4be3c1f..709f2d7 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor @@ -1,12 +1,13 @@ @using MatrixRoomUtils.Core.StateEventTypes @using MatrixRoomUtils.Core.StateEventTypes.Spec +@using MatrixRoomUtils.Web.Classes.Constants
@roomType (@rooms.Count) @foreach (var room in rooms) {
- @if (room.StateEvents.Any(x => x.Type == "m.room.create")) { - + @if (RoomVersionDangerLevel(room) != 0) { + Upgrade room } View timeline View state @@ -30,5 +31,15 @@ private string roomType => Category.Key; private List rooms => Category.Value; - + + private int RoomVersionDangerLevel(RoomInfo room) { + var roomVersion = room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.create"); + if (roomVersion is null) return 0; + var roomVersionContent = roomVersion.TypedContent as RoomCreateEventData; + if (roomVersionContent is null) return 0; + if (RoomConstants.DangerousRoomVersions.Contains(roomVersionContent.RoomVersion)) return 2; + if (roomVersionContent.RoomVersion != RoomConstants.RecommendedRoomVersion) return 1; + return 0; + } + } \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor b/MatrixRoomUtils.Web/Shared/RoomListItem.razor index d35c9ab..b89fb18 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor @@ -3,6 +3,7 @@ @using MatrixRoomUtils.Core.Helpers @using MatrixRoomUtils.Core.StateEventTypes @using MatrixRoomUtils.Core.StateEventTypes.Spec +@using MatrixRoomUtils.Web.Classes.Constants
@if (OwnMemberState != null) { + @ChildContent @@ -9,5 +9,8 @@ [Parameter] public RenderFragment ChildContent { get; set; } - + + [Parameter] + public string? Color { get; set; } + } \ No newline at end of file -- cgit 1.5.1