diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-04 00:13:25 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-04 00:18:46 +0200 |
commit | b933f7ed1189c7e14d82b4fcf5c98fb3ef4b9cf1 (patch) | |
tree | 4176eb2b7f1befca685d00e119d842eb3f07da1f /MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor | |
parent | Small refactoring (diff) | |
download | MatrixUtils-b933f7ed1189c7e14d82b4fcf5c98fb3ef4b9cf1.tar.xz |
Refactoring
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor index d0fb2f0..08161b2 100644 --- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor +++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor @@ -1,44 +1,45 @@ -@using MatrixRoomUtils.Authentication @using MatrixRoomUtils.Web.Classes @using System.Text.Json @using Blazored.LocalStorage -@using MatrixRoomUtils.Extensions +@using MatrixRoomUtils.Core +@using MatrixRoomUtils.Core.Extensions @using Index = MatrixRoomUtils.Web.Pages.Index +@using System.ComponentModel.DataAnnotations @inject ILocalStorageService LocalStorage @inject NavigationManager NavigationManager <div style="margin-bottom: 1em;"> <img style="border-radius: 50%; height: 3em; width: 3em;" src="@_avatarUrl"/> - <span style="margin-left: 1em;"><input type="radio" name="csa" checked="@(RuntimeCache.AccessToken == User.AccessToken)" onclick="@SetCurrent" style="text-decoration-line: unset;"/> <b>@User.Profile.DisplayName</b> on <b>@User.LoginResponse.HomeServer</b></span> + <span style="margin-left: 1em;"><input type="radio" name="csa" checked="@(RuntimeCache.LastUsedToken == User.AccessToken)" onclick="@SetCurrent" style="text-decoration-line: unset;"/> <b>@User.Profile.DisplayName</b> on <b>@User.LoginResponse.HomeServer</b></span> <a href="#" onclick="@RemoveUser">Remove</a> </div> @code { + [Parameter] - public UserInfo User { get; set; } + public UserInfo User { get; set; } = null!; private string _avatarUrl { get; set; } - private bool _removed { get; set; } = false; protected override async Task OnInitializedAsync() { - if(User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "") - _avatarUrl = await User.Profile.AvatarUrl.GetMediaUrl(); + if (User.Profile.AvatarUrl != null && User.Profile.AvatarUrl != "") + _avatarUrl = await (await new AuthenticatedHomeServer(User.LoginResponse.UserId, User.AccessToken, User.LoginResponse.HomeServer).Configure()).ResolveMediaUri(User.Profile.AvatarUrl); else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId; await base.OnInitializedAsync(); } private async Task RemoveUser() { + Console.WriteLine(User.ToJson()); RuntimeCache.LoginSessions.Remove(User.AccessToken); await LocalStorageWrapper.ReloadLocalStorage(LocalStorage); - _removed = true; StateHasChanged(); } private async Task SetCurrent() { - RuntimeCache.AccessToken = User.AccessToken; + RuntimeCache.LastUsedToken = User.AccessToken; //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer); await LocalStorageWrapper.ReloadLocalStorage(LocalStorage); |