From e6fe1eacc36245c9799afae6e4dfaecb62ea65d6 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Thu, 26 Oct 2023 13:15:18 +0000 Subject: Changes, fixes --- MatrixRoomUtils.Web/Pages/Index.razor | 52 +++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'MatrixRoomUtils.Web/Pages/Index.razor') diff --git a/MatrixRoomUtils.Web/Pages/Index.razor b/MatrixRoomUtils.Web/Pages/Index.razor index 00f3253..74dd651 100644 --- a/MatrixRoomUtils.Web/Pages/Index.razor +++ b/MatrixRoomUtils.Web/Pages/Index.razor @@ -14,28 +14,31 @@ Small collection of tools to do not-so-everyday things.
- @foreach (var (auth, user) in _users.OrderByDescending(x => x.Value.RoomCount)) { - var _auth = auth; + @foreach (var __auth in _auth.OrderByDescending(x => x.UserInfo.RoomCount)) { + var _auth = __auth.UserAuth;
- +

- Manage + Manage Remove Log out

@@ -48,11 +51,19 @@ Small collection of tools to do not-so-everyday things. @code { - private Dictionary _users = new(); + private class AuthInfo { + public UserAuth UserAuth { get; set; } + public UserInfo UserInfo { get; set; } + public ServerVersionResponse ServerVersion { get; set; } + } + + // private Dictionary _users = new(); + private List _auth = new(); protected override async Task OnInitializedAsync() { _currentSession = await MRUStorage.GetCurrentToken(); - _users.Clear(); + // _users.Clear(); + _auth.Clear(); var tokens = await MRUStorage.GetAllTokens(); var profileTasks = tokens.Select(async token => { UserInfo userInfo = new(); @@ -73,7 +84,12 @@ Small collection of tools to do not-so-everyday things. Console.WriteLine(profile.ToJson()); userInfo.AvatarUrl = string.IsNullOrWhiteSpace(profile.AvatarUrl) ? "https://api.dicebear.com/6.x/identicon/svg?seed=" + hs.WhoAmI.UserId : hs.ResolveMediaUri(profile.AvatarUrl); userInfo.RoomCount = (await roomCountTask).Count; - _users.Add(token, userInfo); + // _users.Add(token, userInfo); + _auth.Add(new() { + UserInfo = userInfo, + UserAuth = token, + ServerVersion = await hs.GetServerVersionAsync() + }); // StateHasChanged(); }); await Task.WhenAll(profileTasks); @@ -93,8 +109,8 @@ Small collection of tools to do not-so-everyday things. } } catch (Exception e) { - if(e is MatrixException {ErrorCode: "M_UNKNOWN_TOKEN" }) { - //todo: handle this + if (e is MatrixException {ErrorCode: "M_UNKNOWN_TOKEN" }) { + //todo: handle this return; } Console.WriteLine(e); @@ -115,6 +131,6 @@ Small collection of tools to do not-so-everyday things. private async Task ManageUser(UserAuth auth) { await SwitchSession(auth); - NavigationManager.NavigateTo("/User/Manage"); + NavigationManager.NavigateTo("/User/Profile"); } -} +} \ No newline at end of file -- cgit 1.4.1