From 3ef3e5caa65458e595e2303358322626c7da1dda Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 23 May 2023 08:51:02 +0200 Subject: Add numerous new things --- .../Shared/IndexComponents/IndexUserItem.razor | 24 +++++++++++----- MatrixRoomUtils.Web/Shared/LogView.razor | 26 +++++++++++++---- MatrixRoomUtils.Web/Shared/MainLayout.razor | 14 +++++++-- MatrixRoomUtils.Web/Shared/NavMenu.razor | 9 ++++-- MatrixRoomUtils.Web/Shared/PortableDevTools.razor | 31 ++++++++++++++++++++ MatrixRoomUtils.Web/Shared/RoomListItem.razor | 33 ++++++++++++++++------ 6 files changed, 111 insertions(+), 26 deletions(-) create mode 100644 MatrixRoomUtils.Web/Shared/PortableDevTools.razor (limited to 'MatrixRoomUtils.Web/Shared') diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor index 08161b2..87ef831 100644 --- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor +++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor @@ -10,22 +10,30 @@
- @User.Profile.DisplayName on @User.LoginResponse.HomeServer - Remove +

+ + @User.Profile.DisplayName on @User.LoginResponse.HomeServer + Remove +

+

Member of @_roomCount rooms

+
@code { [Parameter] public UserInfo User { get; set; } = null!; - + private string _avatarUrl { get; set; } + private int _roomCount { get; set; } = 0; protected override async Task OnInitializedAsync() { + var hs = await new AuthenticatedHomeServer(User.LoginResponse.UserId, User.AccessToken, User.LoginResponse.HomeServer).Configure(); 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); + _avatarUrl = await hs.ResolveMediaUri(User.Profile.AvatarUrl); else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId; + _roomCount = (await hs.GetJoinedRooms()).Count; await base.OnInitializedAsync(); } @@ -34,15 +42,17 @@ Console.WriteLine(User.ToJson()); RuntimeCache.LoginSessions.Remove(User.AccessToken); await LocalStorageWrapper.ReloadLocalStorage(LocalStorage); - + StateHasChanged(); } + private async Task SetCurrent() { RuntimeCache.LastUsedToken = User.AccessToken; - //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer); + //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer); await LocalStorageWrapper.ReloadLocalStorage(LocalStorage); - + StateHasChanged(); } + } \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor index f60f271..80fd355 100644 --- a/MatrixRoomUtils.Web/Shared/LogView.razor +++ b/MatrixRoomUtils.Web/Shared/LogView.razor @@ -1,13 +1,27 @@ @using System.Text -Logs
-
-    @_stringBuilder
-
+@if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) +{ + Logs +
+
+        @_stringBuilder
+    
+} @code { StringBuilder _stringBuilder = new(); - protected override void OnInitialized() + protected override async Task OnInitializedAsync() { + await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); + if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) + { + Console.WriteLine("Console logging disabled!"); + var _sw = new StringWriter(); + Console.SetOut(_sw); + Console.SetError(_sw); + return; + } + if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) return; //intecept stdout with textwriter to get logs var sw = new StringWriter(_stringBuilder); Console.SetOut(sw); @@ -27,6 +41,6 @@ } // ReSharper disable once FunctionNeverReturns - This is intentional behavior }); - base.OnInitialized(); + await base.OnInitializedAsync(); } } \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/MainLayout.razor b/MatrixRoomUtils.Web/Shared/MainLayout.razor index da27978..b1b0b53 100644 --- a/MatrixRoomUtils.Web/Shared/MainLayout.razor +++ b/MatrixRoomUtils.Web/Shared/MainLayout.razor @@ -1,5 +1,4 @@ -@using MatrixRoomUtils.Core.Extensions -@using System.Net +@using System.Net @inherits LayoutComponentBase
@@ -9,6 +8,7 @@
+ Git Matrix @if (showDownload) @@ -31,6 +31,16 @@ using var hc = new HttpClient(); var hr = await hc.SendAsync(new(HttpMethod.Head, NavigationManager.ToAbsoluteUri("/MRU-BIN.tar.xz").AbsoluteUri)); showDownload = hr.StatusCode == HttpStatusCode.OK; + + await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); + if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) + { + Console.WriteLine("Console logging disabled!"); + var sw = new StringWriter(); + Console.SetOut(sw); + Console.SetError(sw); + } + await base.OnInitializedAsync(); } diff --git a/MatrixRoomUtils.Web/Shared/NavMenu.razor b/MatrixRoomUtils.Web/Shared/NavMenu.razor index b77935d..8136715 100644 --- a/MatrixRoomUtils.Web/Shared/NavMenu.razor +++ b/MatrixRoomUtils.Web/Shared/NavMenu.razor @@ -52,10 +52,15 @@
+ @* *@