diff options
author | Emma@Rory& <root@rory.gay> | 2023-09-19 00:17:18 +0200 |
---|---|---|
committer | Emma@Rory& <root@rory.gay> | 2023-09-19 00:17:18 +0200 |
commit | ec1752307a4a273324cd8f13bb099fed6ff7ef3a (patch) | |
tree | 5d287d992aa49d6d7f898198a6e769314f65f8eb /MatrixRoomUtils.Web | |
parent | Refactors (diff) | |
download | MatrixUtils-ec1752307a4a273324cd8f13bb099fed6ff7ef3a.tar.xz |
Refactors
Diffstat (limited to 'MatrixRoomUtils.Web')
23 files changed, 70 insertions, 60 deletions
diff --git a/MatrixRoomUtils.Web/Classes/Constants/RoomConstants.cs b/MatrixRoomUtils.Web/Classes/Constants/RoomConstants.cs index da6bf0d..b145cd0 100644 --- a/MatrixRoomUtils.Web/Classes/Constants/RoomConstants.cs +++ b/MatrixRoomUtils.Web/Classes/Constants/RoomConstants.cs @@ -1,7 +1,6 @@ -namespace MatrixRoomUtils.Web.Classes.Constants; +namespace MatrixRoomUtils.Web.Classes.Constants; public class RoomConstants { - public static readonly string[] DangerousRoomVersions = { "1", "8" }; public const string RecommendedRoomVersion = "10"; -} \ No newline at end of file +} diff --git a/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs b/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs index 3f67f33..1fa56be 100644 --- a/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs +++ b/MatrixRoomUtils.Web/Classes/RoomCreationTemplates/DefaultRoomCreationTemplate.cs @@ -1,7 +1,7 @@ using System.Text.Json.Nodes; using LibMatrix; +using LibMatrix.EventTypes.Spec.State; using LibMatrix.Responses; -using LibMatrix.StateEventTypes.Spec; namespace MatrixRoomUtils.Web.Classes.RoomCreationTemplates; diff --git a/MatrixRoomUtils.Web/Pages/About.razor b/MatrixRoomUtils.Web/Pages/About.razor index 17ed04a..df6e6c2 100644 --- a/MatrixRoomUtils.Web/Pages/About.razor +++ b/MatrixRoomUtils.Web/Pages/About.razor @@ -13,23 +13,23 @@ <br/><br/> <p>You can find the source code on <a href="https://git.rory.gay/MatrixRoomUtils.git/">my git server</a>.<br/></p> <p>You can also join the <a href="https://matrix.to/#/%23mru%3Arory.gay?via=rory.gay&via=matrix.org&via=feline.support">Matrix room</a> for this project.</p> -@if (showBinDownload) { +@if (ShowBinDownload) { <p>This deployment also serves a copy of the compiled, hosting-ready binaries at <a href="MRU-BIN.tar.xz">/MRU-BIN.tar.xz</a>!</p> } -@if (showSrcDownload) { +@if (ShowSrcDownload) { <p>This deployment also serves a copy of the compiled, hosting-ready binaries at <a href="MRU-SRC.tar.xz">/MRU-SRC.tar.xz</a>!</p> } @code { - private bool showBinDownload { get; set; } - private bool showSrcDownload { get; set; } + private bool ShowBinDownload { get; set; } + private bool ShowSrcDownload { get; set; } protected override async Task OnInitializedAsync() { using var hc = new HttpClient(); var hr = await hc.SendAsync(new HttpRequestMessage(HttpMethod.Head, NavigationManager.ToAbsoluteUri("/MRU-BIN.tar.xz").AbsoluteUri)); - showBinDownload = hr.StatusCode == HttpStatusCode.OK; + ShowBinDownload = hr.StatusCode == HttpStatusCode.OK; hr = await hc.SendAsync(new HttpRequestMessage(HttpMethod.Head, NavigationManager.ToAbsoluteUri("/MRU-SRC.tar.xz").AbsoluteUri)); - showSrcDownload = hr.StatusCode == HttpStatusCode.OK; + ShowSrcDownload = hr.StatusCode == HttpStatusCode.OK; await base.OnInitializedAsync(); } diff --git a/MatrixRoomUtils.Web/Pages/Index.razor b/MatrixRoomUtils.Web/Pages/Index.razor index e02c733..845bbb9 100644 --- a/MatrixRoomUtils.Web/Pages/Index.razor +++ b/MatrixRoomUtils.Web/Pages/Index.razor @@ -26,6 +26,9 @@ Small collection of tools to do not-so-everyday things. <p> <input type="radio" name="csa" checked="@(_currentSession.AccessToken == _auth.AccessToken)" @onclick="@(() => SwitchSession(_auth))" style="text-decoration-line: unset;"/> <b>@user.DisplayName</b> on <b>@_auth.Homeserver</b> + @if (_auth.Proxy != null) { + <span class="badge badge-info"> (proxied via @_auth.Proxy)</span> + } </p> <p>Member of @user.RoomCount rooms</p> @@ -35,6 +38,7 @@ Small collection of tools to do not-so-everyday things. <p> <LinkButton href="">Manage</LinkButton> <LinkButton OnClick="@(() => RemoveUser(_auth))">Remove</LinkButton> + <LinkButton OnClick="@(() => RemoveUser(_auth, true))">Log out</LinkButton> </p> </td> @* </div> *@ @@ -55,7 +59,7 @@ Small collection of tools to do not-so-everyday things. UserInfo userInfo = new(); AuthenticatedHomeserverGeneric hs; try { - hs = await HomeserverProvider.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken); + hs = await hsProvider.GetAuthenticatedWithToken(token.Homeserver, token.AccessToken); } catch (MatrixException e) { if (e.ErrorCode == "M_UNKNOWN_TOKEN") { @@ -65,10 +69,10 @@ Small collection of tools to do not-so-everyday things. throw; } var roomCountTask = hs.GetJoinedRooms(); - var profile = await hs.GetProfile(hs.WhoAmI.UserId); + var profile = await hs.GetProfileAsync(hs.WhoAmI.UserId); userInfo.DisplayName = profile.DisplayName ?? hs.WhoAmI.UserId; Console.WriteLine(profile.ToJson()); - userInfo.AvatarUrl = MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, + userInfo.AvatarUrl = await hsResolver.ResolveMediaUri(hs.FullHomeServerDomain, profile.AvatarUrl ?? "https://api.dicebear.com/6.x/identicon/svg?seed=" + hs.WhoAmI.UserId ); @@ -86,10 +90,22 @@ Small collection of tools to do not-so-everyday things. internal int RoomCount { get; set; } } - private async Task RemoveUser(UserAuth auth) { + private async Task RemoveUser(UserAuth auth, bool logout = false) { + try { + if (logout) { + await (await hsProvider.GetAuthenticatedWithToken(auth.Homeserver, auth.AccessToken)).Logout(); + } + } + catch (Exception e) { + if(e is MatrixException {ErrorCode: "M_UNKNOWN_TOKEN" }) { + //todo: handle this + return; + } + Console.WriteLine(e); + } await MRUStorage.RemoveToken(auth); - if ((await MRUStorage.GetCurrentToken()).AccessToken == auth.AccessToken) - MRUStorage.SetCurrentToken((await MRUStorage.GetAllTokens()).FirstOrDefault()); + if ((await MRUStorage.GetCurrentToken())?.AccessToken == auth.AccessToken) + await MRUStorage.SetCurrentToken((await MRUStorage.GetAllTokens() ?? throw new InvalidOperationException()).FirstOrDefault()); await OnInitializedAsync(); } diff --git a/MatrixRoomUtils.Web/Pages/InvalidSession.razor b/MatrixRoomUtils.Web/Pages/InvalidSession.razor index 310abb1..b476c68 100644 --- a/MatrixRoomUtils.Web/Pages/InvalidSession.razor +++ b/MatrixRoomUtils.Web/Pages/InvalidSession.razor @@ -78,7 +78,7 @@ else { private async Task TryLogin() { if(_login is null) throw new NullReferenceException("Login is null!"); try { - var result = new UserAuth(await HomeserverProvider.Login(_login.Homeserver, _login.UserId, _password)); + var result = new UserAuth(await hsProvider.Login(_login.Homeserver, _login.UserId, _password)); if (result is null) { Console.WriteLine($"Failed to login to {_login.Homeserver} as {_login.UserId}!"); return; diff --git a/MatrixRoomUtils.Web/Pages/LoginPage.razor b/MatrixRoomUtils.Web/Pages/LoginPage.razor index a6ce469..c7f5922 100644 --- a/MatrixRoomUtils.Web/Pages/LoginPage.razor +++ b/MatrixRoomUtils.Web/Pages/LoginPage.razor @@ -70,7 +70,7 @@ var (homeserver, username, password, proxy) = record; if (LoggedInSessions.Any(x => x.UserId == $"@{username}:{homeserver}" && x.Proxy == proxy)) return; try { - var result = new UserAuth(await HomeserverProvider.Login(homeserver, username, password, proxy)) { + var result = new UserAuth(await hsProvider.Login(homeserver, username, password, proxy)) { Proxy = proxy }; if (result == null) { diff --git a/MatrixRoomUtils.Web/Pages/MediaLocator.razor b/MatrixRoomUtils.Web/Pages/MediaLocator.razor index 42c7b8e..e1686b9 100644 --- a/MatrixRoomUtils.Web/Pages/MediaLocator.razor +++ b/MatrixRoomUtils.Web/Pages/MediaLocator.razor @@ -95,7 +95,7 @@ lines.ToList().ForEach(async line => { await sem.WaitAsync(); try { - homeservers.Add(await HomeserverResolver.ResolveHomeserverFromWellKnown(line)); + homeservers.Add(await hsResolver.ResolveHomeserverFromWellKnown(line)); StateHasChanged(); } catch (Exception e) { diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Create.razor b/MatrixRoomUtils.Web/Pages/Rooms/Create.razor index c6fd5b6..5202c40 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/Create.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/Create.razor @@ -3,11 +3,11 @@ @using System.Reflection @using ArcaneLibs.Extensions @using LibMatrix +@using LibMatrix.EventTypes.Spec.State @using LibMatrix.Extensions @using LibMatrix.Helpers @using LibMatrix.Homeservers @using LibMatrix.Responses -@using LibMatrix.StateEventTypes.Spec @using MatrixRoomUtils.Web.Classes.RoomCreationTemplates @* @* ReSharper disable once RedundantUsingDirective - Must not remove this, Rider marks this as "unused" when it's not */ *@ @@ -90,7 +90,7 @@ <tr> <td>Room icon:</td> <td> - <img src="@MediaResolver.ResolveMediaUri(HomeServer.HomeServerDomain, roomAvatarEvent.Url)" style="width: 128px; height: 128px; border-radius: 50%;"/> + <img src="@hsResolver.ResolveMediaUri(HomeServer.HomeServerDomain, roomAvatarEvent.Url)" style="width: 128px; height: 128px; border-radius: 50%;"/> <div style="display: inline-block; vertical-align: middle;"> <FancyTextBox @bind-Value="@roomAvatarEvent.Url"></FancyTextBox><br/> <InputFile OnChange="RoomIconFilePicked"></InputFile> diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor index c2daba7..99e8cbb 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor @@ -1,8 +1,8 @@ @page "/Rooms" -@using LibMatrix.StateEventTypes.Spec @using LibMatrix.Filters @using LibMatrix.Helpers @using LibMatrix.Responses +@using LibMatrix.EventTypes.Spec.State <h3>Room list</h3> <p>@Status</p> @@ -55,7 +55,7 @@ protected override async Task OnInitializedAsync() { var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - GlobalProfile = await hs.GetProfile(hs.WhoAmI.UserId); + GlobalProfile = await hs.GetProfileAsync(hs.WhoAmI.UserId); Status = "Syncing..."; SyncResult? sync = null; @@ -75,7 +75,7 @@ } else { room = new RoomInfo { - Room = await hs.GetRoom(roomId), + Room = hs.GetRoom(roomId), StateEvents = new List<StateEventResponse?>() }; Rooms.Add(room); @@ -135,7 +135,7 @@ // if (res is not null) { // foreach (var (roomId, roomData) in res.Rooms.Join) { // var room = new RoomInfo() { - // Room = await hs.GetRoom(roomId), + // Room = hs.GetRoom(roomId), // StateEvents = roomData.State.Events.Where(x => x.Type == "m.room.member" && x.StateKey == hs.WhoAmI.UserId).ToList() // }; // Rooms.Add(room); diff --git a/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor b/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor index d2b8360..e6f436e 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor @@ -4,8 +4,8 @@ @using LibMatrix.Helpers @using LibMatrix.Homeservers @using LibMatrix.Responses -@using LibMatrix.StateEventTypes.Spec @using ArcaneLibs.Extensions +@using LibMatrix.EventTypes.Spec.State <h3>Policy list editor - Editing @RoomId</h3> <hr/> @@ -212,7 +212,7 @@ else { var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - var room = await hs.GetRoom(RoomId); + var room = hs.GetRoom(RoomId); var states = room.GetFullStateAsync(); await foreach (var state in states) { @@ -234,8 +234,8 @@ else { var hs = userId.Split(':')[1]; var server = servers.ContainsKey(hs) ? servers[hs] : new RemoteHomeServer(userId.Split(':')[1]); if (!servers.ContainsKey(hs)) servers.Add(hs, server); - var profile = await server.GetProfile(userId); - avatars.Add(userId, MediaResolver.ResolveMediaUri(server.FullHomeServerDomain, profile.AvatarUrl)); + var profile = await server.GetProfileAsync(userId); + avatars.Add(userId, await hsResolver.ResolveMediaUri(server.FullHomeServerDomain, profile.AvatarUrl)); servers.Add(userId, server); StateHasChanged(); } diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Space.razor b/MatrixRoomUtils.Web/Pages/Rooms/Space.razor index ef0ea5a..9474b21 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/Space.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/Space.razor @@ -35,14 +35,14 @@ var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - Room = await hs.GetRoom(RoomId.Replace('~', '.')); + Room = hs.GetRoom(RoomId.Replace('~', '.')); var state = Room.GetFullStateAsync(); await foreach (var stateEvent in state) { switch (stateEvent.Type) { case "m.space.child": { var roomId = stateEvent.StateKey; - var room = await hs.GetRoom(roomId); + var room = hs.GetRoom(roomId); if (room is not null) { Rooms.Add(room); } @@ -68,7 +68,7 @@ // if (stateEvent.Type == "m.space.child") { // // if (stateEvent.Content.ToJson().Length < 5) return; // var roomId = stateEvent.StateKey; - // var room = await hs.GetRoom(roomId); + // var room = hs.GetRoom(roomId); // if (room is not null) { // Rooms.Add(room); // } diff --git a/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor b/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor index fefcabc..f7a6106 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor @@ -59,7 +59,7 @@ var hs = await MRUStorage.GetCurrentSessionOrNavigate(); var StateLoaded = 0; - var response = (await hs.GetRoom(RoomId)).GetFullStateAsync(); + var response = (hs.GetRoom(RoomId)).GetFullStateAsync(); await foreach (var _ev in response) { // var e = new StateEventResponse { // Type = _ev.Type, diff --git a/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor b/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor index 1c3f28b..6e8fe2f 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor @@ -83,7 +83,7 @@ var StateLoaded = 0; var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - var response = (await hs.GetRoom(RoomId)).GetFullStateAsync(); + var response = (hs.GetRoom(RoomId)).GetFullStateAsync(); await foreach (var _ev in response) { Events.Add(_ev); if (string.IsNullOrEmpty(_ev.StateKey)) { diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor b/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor index 2c95c99..68125cb 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor @@ -1,9 +1,10 @@ @page "/Rooms/{RoomId}/Timeline" @using MatrixRoomUtils.Web.Shared.TimelineComponents @using LibMatrix +@using LibMatrix.EventTypes.Spec +@using LibMatrix.EventTypes.Spec.State @using LibMatrix.Homeservers @using LibMatrix.Responses -@using LibMatrix.StateEventTypes.Spec <h3>RoomManagerTimeline</h3> <hr/> <p>Loaded @Events.Count events...</p> @@ -30,7 +31,7 @@ Console.WriteLine("RoomId: " + RoomId); HomeServer = await MRUStorage.GetCurrentSessionOrNavigate(); if (HomeServer is null) return; - var room = await HomeServer.GetRoom(RoomId); + var room = HomeServer.GetRoom(RoomId); MessagesResponse? msgs = null; do { msgs = await room.GetMessagesAsync(limit: 1000, from: msgs?.End, dir: "b"); diff --git a/MatrixRoomUtils.Web/Pages/SpaceDebug.razor b/MatrixRoomUtils.Web/Pages/SpaceDebug.razor index c4c4ce8..1ad6276 100644 --- a/MatrixRoomUtils.Web/Pages/SpaceDebug.razor +++ b/MatrixRoomUtils.Web/Pages/SpaceDebug.razor @@ -1,5 +1,4 @@ @page "/SpaceDebug" -@using LibMatrix.StateEventTypes.Spec @using LibMatrix.RoomTypes @using LibMatrix.Filters <h3>SpaceDebug</h3> 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 <div style="background-color: #ffffff11; border-radius: 0.5em; height: 1em; display: inline-block; vertical-align: middle;" alt="@UserId"> @@ -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)) { <p>Fetching room details... @RoomsWithTypes.Sum(x=>x.Value.Count) out of @Rooms.Count done!</p> @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 <details> <summary>@roomType (@rooms.Count)</summary> 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 <div class="roomListItem" id="@RoomId" style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content; @(hasDangerousRoomVersion ? "border: red 4px solid;" : hasOldRoomVersion ? "border: #FF0 1px solid;" : "")"> @if (OwnMemberState != null) { <img class="imageUnloaded @(string.IsNullOrWhiteSpace(OwnMemberState?.AvatarUrl ?? GlobalProfile?.AvatarUrl) ? "" : "imageLoaded")" style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%; @(OwnMemberState?.AvatarUrl != GlobalProfile?.AvatarUrl ? "border-color: red; border-width: 3px; border-style: dashed;" : "")" - src="@MediaResolver.ResolveMediaUri(hs.FullHomeServerDomain, OwnMemberState.AvatarUrl ?? GlobalProfile.AvatarUrl ?? "/icon-192.png")"/> + src="@hsResolver.ResolveMediaUri(hs.FullHomeServerDomain, OwnMemberState.AvatarUrl ?? GlobalProfile.AvatarUrl ?? "/icon-192.png").Result"/> <span style="vertical-align: middle; margin-right: 8px; border-radius: 75px; @(OwnMemberState?.AvatarUrl != GlobalProfile?.AvatarUrl ? "background-color: red;" : "")"> @(OwnMemberState?.Displayname ?? GlobalProfile?.DisplayName ?? "Loading...") </span> @@ -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 <p> 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 <div style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content;"> <img style="@(ChildContent is not null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@profileAvatar"/> <span style="vertical-align: middle; margin-right: 8px; border-radius: 75px;">@profileName</span> @@ -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(); diff --git a/MatrixRoomUtils.Web/_Imports.razor b/MatrixRoomUtils.Web/_Imports.razor index a92153d..91b69fb 100644 --- a/MatrixRoomUtils.Web/_Imports.razor +++ b/MatrixRoomUtils.Web/_Imports.razor @@ -16,7 +16,7 @@ @inject NavigationManager NavigationManager @inject MRUStorageWrapper MRUStorage -@inject HomeserverProviderService HomeserverProvider +@inject HomeserverProviderService hsProvider @inject TieredStorageService TieredStorage -@inject HomeserverResolverService HomeserverResolver +@inject HomeserverResolverService hsResolver @inject IJSRuntime JSRuntime |