diff options
Diffstat (limited to 'MatrixRoomUtils.Web/Shared')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor | 19 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/LogView.razor | 11 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/MainLayout.razor | 5 |
3 files changed, 18 insertions, 17 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); diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor index fbe5264..f60f271 100644 --- a/MatrixRoomUtils.Web/Shared/LogView.razor +++ b/MatrixRoomUtils.Web/Shared/LogView.razor @@ -1,15 +1,15 @@ @using System.Text <u>Logs</u><br/> <pre> - @sb + @_stringBuilder </pre> @code { - StringBuilder sb = new(); + StringBuilder _stringBuilder = new(); protected override void OnInitialized() { //intecept stdout with textwriter to get logs - var sw = new StringWriter(sb); + var sw = new StringWriter(_stringBuilder); Console.SetOut(sw); Console.SetError(sw); //keep updated @@ -19,12 +19,13 @@ while (true) { await Task.Delay(100); - if (sb.Length != length) + if (_stringBuilder.Length != length) { StateHasChanged(); - length = sb.Length; + length = _stringBuilder.Length; } } + // ReSharper disable once FunctionNeverReturns - This is intentional behavior }); base.OnInitialized(); } diff --git a/MatrixRoomUtils.Web/Shared/MainLayout.razor b/MatrixRoomUtils.Web/Shared/MainLayout.razor index 055cec7..4aa01c6 100644 --- a/MatrixRoomUtils.Web/Shared/MainLayout.razor +++ b/MatrixRoomUtils.Web/Shared/MainLayout.razor @@ -1,6 +1,4 @@ @inherits LayoutComponentBase -@inject ILocalStorageService LocalStorage -@inject NavigationManager NavigationManager <div class="page"> <div class="sidebar"> @@ -9,7 +7,8 @@ <main> <div class="top-row px-4"> - <a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a> + <a href="https://git.rory.gay/MatrixRoomUtils.git/" target="_blank">Git</a> + <a href="https://matrix.to/#/%23mru%3Arory.gay?via=rory.gay&via=matrix.org&via=feline.support" target="_blank">Matrix</a> </div> <article class="content px-4"> |