From df9031c47f8e97d8e2df3177093271a458f27267 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 1 May 2023 02:43:32 +0200 Subject: Initial commit --- .../Shared/IndexComponents/IndexUserItem.razor | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor (limited to 'MatrixRoomUtils.Web/Shared/IndexComponents') diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor new file mode 100644 index 0000000..cc6f9f6 --- /dev/null +++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor @@ -0,0 +1,49 @@ +@using MatrixRoomUtils.Authentication +@using MatrixRoomUtils.Web.Classes +@using System.Text.Json +@using Blazored.LocalStorage +@using MatrixRoomUtils.Extensions +@using Index = MatrixRoomUtils.Web.Pages.Index +@inject ILocalStorageService LocalStorage +@inject NavigationManager NavigationManager + +
+ + @User.Profile.DisplayName on @User.LoginResponse.HomeServer + Remove +
+ +@code { + [Parameter] + public string Token { get; set; } + [Parameter] + public UserInfo User { get; set; } + + 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(); + else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId; + await base.OnInitializedAsync(); + } + + private async Task RemoveUser() + { + RuntimeStorage.UsersCache.Remove(Token); + await RuntimeStorage.SaveToLocalStorage(LocalStorage); + _removed = true; + + StateHasChanged(); + } + private async Task SetCurrent() + { + RuntimeStorage.AccessToken = Token; + RuntimeStorage.CurrentHomeserver = await MatrixAccount.ResolveHomeserverFromWellKnown(RuntimeStorage.UsersCache[Token].LoginResponse.HomeServer); + await RuntimeStorage.SaveToLocalStorage(LocalStorage); + + StateHasChanged(); + } +} \ No newline at end of file -- cgit 1.4.1