From ec1752307a4a273324cd8f13bb099fed6ff7ef3a Mon Sep 17 00:00:00 2001 From: "Emma@Rory&" Date: Tue, 19 Sep 2023 00:17:18 +0200 Subject: Refactors --- MatrixRoomUtils.Web/Shared/InlineUserItem.razor | 7 +++---- MatrixRoomUtils.Web/Shared/RoomList.razor | 5 ++--- .../Shared/RoomListComponents/RoomListCategory.razor | 3 +-- MatrixRoomUtils.Web/Shared/RoomListItem.razor | 11 +++++------ .../Shared/TimelineComponents/TimelineMemberItem.razor | 2 +- .../Shared/TimelineComponents/TimelineRoomCreateItem.razor | 2 +- MatrixRoomUtils.Web/Shared/UserListItem.razor | 7 +++---- 7 files changed, 16 insertions(+), 21 deletions(-) (limited to 'MatrixRoomUtils.Web/Shared') diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor index af2fa29..e82b505 100644 --- a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor +++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor @@ -1,6 +1,5 @@ -@using LibMatrix.StateEventTypes -@using LibMatrix.StateEventTypes.Spec @using LibMatrix +@using LibMatrix.EventTypes.Spec.State @using LibMatrix.Helpers @using LibMatrix.Homeservers
@@ -58,11 +57,11 @@ } if (User is null && UserId is not null) { - User ??= await HomeServer.GetProfile(UserId); + User ??= await HomeServer.GetProfileAsync(UserId); } - ProfileAvatar ??= MediaResolver.ResolveMediaUri(HomeServer.FullHomeServerDomain, User.AvatarUrl); + ProfileAvatar ??= await hsResolver.ResolveMediaUri(HomeServer.FullHomeServerDomain, User.AvatarUrl); ProfileName ??= User.DisplayName; _semaphoreSlim.Release(); diff --git a/MatrixRoomUtils.Web/Shared/RoomList.razor b/MatrixRoomUtils.Web/Shared/RoomList.razor index b0548cb..91ebb0b 100644 --- a/MatrixRoomUtils.Web/Shared/RoomList.razor +++ b/MatrixRoomUtils.Web/Shared/RoomList.razor @@ -1,9 +1,8 @@ @using MatrixRoomUtils.Web.Shared.RoomListComponents; -@using LibMatrix.StateEventTypes -@using LibMatrix.StateEventTypes.Spec @using LibMatrix @using LibMatrix.Extensions @using ArcaneLibs.Extensions +@using LibMatrix.EventTypes.Spec.State @if(Rooms.Count != RoomsWithTypes.Sum(x=>x.Value.Count)) {

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

@foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) { @@ -29,7 +28,7 @@ else { var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - GlobalProfile ??= await hs.GetProfile(hs.WhoAmI.UserId); + GlobalProfile ??= await hs.GetProfileAsync(hs.WhoAmI.UserId); if (RoomsWithTypes.Any()) return; var tasks = Rooms.Select(ProcessRoom); diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor index d717186..27084cc 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor @@ -1,7 +1,6 @@ -@using LibMatrix.StateEventTypes @using MatrixRoomUtils.Web.Classes.Constants -@using LibMatrix.StateEventTypes.Spec @using LibMatrix +@using LibMatrix.EventTypes.Spec.State @using LibMatrix.Homeservers
@roomType (@rooms.Count) diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor b/MatrixRoomUtils.Web/Shared/RoomListItem.razor index b74643b..d83568e 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor @@ -1,16 +1,15 @@ @using System.Text.Json @using LibMatrix +@using LibMatrix.EventTypes.Spec.State @using LibMatrix.Helpers @using LibMatrix.Homeservers @using LibMatrix.RoomTypes -@using LibMatrix.StateEventTypes.Spec -@using LibMatrix.StateEventTypes @using MatrixRoomUtils.Web.Classes.Constants
@if (OwnMemberState != null) { + src="@hsResolver.ResolveMediaUri(hs.FullHomeServerDomain, OwnMemberState.AvatarUrl ?? GlobalProfile.AvatarUrl ?? "/icon-192.png").Result"/> @(OwnMemberState?.Displayname ?? GlobalProfile?.DisplayName ?? "Loading...") @@ -77,7 +76,7 @@ if(Room is not null) RoomId = Room.RoomId; //sweep from id to roominfo - if(RoomId is not null) Room ??= await hs.GetRoom(RoomId); + if(RoomId is not null) Room ??= hs.GetRoom(RoomId); if(Room is not null) RoomInfo ??= new RoomInfo { Room = Room }; @@ -104,7 +103,7 @@ if (!ShowOwnProfile) return; try { OwnMemberState ??= (await RoomInfo.GetStateEvent("m.room.member", hs.UserId)).TypedContent as RoomMemberEventContent; - GlobalProfile ??= await hs.GetProfile(hs.UserId); + GlobalProfile ??= await hs.GetProfileAsync(hs.UserId); } catch (MatrixException e) { if (e is { ErrorCode: "M_FORBIDDEN" }) { @@ -138,7 +137,7 @@ var state = (await RoomInfo.GetStateEvent("m.room.avatar")).TypedContent as RoomAvatarEventContent; if (state?.Url is { } url) { - roomIcon = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, url); + roomIcon = await hsResolver.ResolveMediaUri(hs.FullHomeServerDomain, url); // Console.WriteLine($"Got avatar for room {RoomId}: {roomIcon} ({url})"); } } diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor index c450211..27c636f 100644 --- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor +++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor @@ -1,6 +1,6 @@ -@using LibMatrix.StateEventTypes.Spec @using LibMatrix.Extensions @using ArcaneLibs.Extensions +@using LibMatrix.EventTypes.Spec.State @inherits BaseTimelineItem @if (roomMemberData is not null) { diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor index 9c48455..ff77726 100644 --- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor +++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineRoomCreateItem.razor @@ -1,6 +1,6 @@ -@using LibMatrix.StateEventTypes.Spec @using LibMatrix.Extensions @using ArcaneLibs.Extensions +@using LibMatrix.EventTypes.Spec.State @inherits BaseTimelineItem

diff --git a/MatrixRoomUtils.Web/Shared/UserListItem.razor b/MatrixRoomUtils.Web/Shared/UserListItem.razor index 7a55380..7c439cd 100644 --- a/MatrixRoomUtils.Web/Shared/UserListItem.razor +++ b/MatrixRoomUtils.Web/Shared/UserListItem.razor @@ -1,6 +1,5 @@ -@using LibMatrix.StateEventTypes -@using LibMatrix.StateEventTypes.Spec @using LibMatrix.Helpers +@using LibMatrix.EventTypes.Spec.State

@profileName @@ -41,11 +40,11 @@ if (UserId == null) { throw new ArgumentNullException(nameof(UserId)); } - User = await hs.GetProfile(UserId); + User = await hs.GetProfileAsync(UserId); } // UserId = User.; - profileAvatar = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl); + profileAvatar = await hsResolver.ResolveMediaUri(hs.FullHomeServerDomain, User.AvatarUrl); profileName = User.DisplayName; _semaphoreSlim.Release(); -- cgit 1.5.1