From 712ad189c99570f686ab779782b2a873e172428e Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 13 Jun 2023 20:25:05 +0200 Subject: Change syntax style --- MatrixRoomUtils.Web/Shared/EditablePre.razor | 10 +-- .../Shared/IndexComponents/IndexUserItem.razor | 23 +++--- MatrixRoomUtils.Web/Shared/InlineUserItem.razor | 22 ++---- MatrixRoomUtils.Web/Shared/LogView.razor | 26 +++---- MatrixRoomUtils.Web/Shared/MainLayout.razor | 17 ++-- MatrixRoomUtils.Web/Shared/MainLayout.razor.css | 24 +++--- MatrixRoomUtils.Web/Shared/NavMenu.razor | 12 ++- MatrixRoomUtils.Web/Shared/NavMenu.razor.css | 36 ++++----- MatrixRoomUtils.Web/Shared/PortableDevTools.razor | 23 +++--- MatrixRoomUtils.Web/Shared/RoomListItem.razor | 91 ++++++++-------------- MatrixRoomUtils.Web/Shared/RoomListItem.razor.css | 6 +- .../Shared/SimpleComponents/DictionaryEditor.razor | 21 +++-- .../Shared/SimpleComponents/FancyTextBox.razor | 20 ++--- .../Shared/SimpleComponents/StringListEditor.razor | 14 ++-- .../Shared/SimpleComponents/ToggleSlider.razor | 6 +- .../TimelineComponents/TimelineMemberItem.razor | 24 ++---- MatrixRoomUtils.Web/Shared/UserListItem.razor | 20 ++--- 17 files changed, 163 insertions(+), 232 deletions(-) (limited to 'MatrixRoomUtils.Web/Shared') diff --git a/MatrixRoomUtils.Web/Shared/EditablePre.razor b/MatrixRoomUtils.Web/Shared/EditablePre.razor index 01bea0d..e759015 100644 --- a/MatrixRoomUtils.Web/Shared/EditablePre.razor +++ b/MatrixRoomUtils.Web/Shared/EditablePre.razor @@ -1,8 +1,9 @@ @inherits InputBase
@CurrentValue
+ @code { - protected override bool TryParseValueFromString(string? value, out string result, out string? validationErrorMessage) - { + + protected override bool TryParseValueFromString(string? value, out string result, out string? validationErrorMessage) { result = value; validationErrorMessage = null; return true; @@ -10,9 +11,6 @@ public object Id { get; set; } - private async Task Callback() - { - Console.WriteLine("beep"); - } + private async Task Callback() => Console.WriteLine("beep"); } \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor index 03a7145..1fc70f2 100644 --- a/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor +++ b/MatrixRoomUtils.Web/Shared/IndexComponents/IndexUserItem.razor @@ -1,10 +1,4 @@ -@using MatrixRoomUtils.Web.Classes -@using System.Text.Json -@using Blazored.LocalStorage -@using MatrixRoomUtils.Core @using MatrixRoomUtils.Core.Extensions -@using Index = MatrixRoomUtils.Web.Pages.Index -@using System.ComponentModel.DataAnnotations @inject ILocalStorageService LocalStorage @inject NavigationManager NavigationManager @@ -27,30 +21,33 @@ private string? _avatarUrl { get; set; } private int _roomCount { get; set; } = 0; - protected override async Task OnInitializedAsync() - { + 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 = hs.ResolveMediaUri(User.Profile.AvatarUrl); else _avatarUrl = "https://api.dicebear.com/6.x/identicon/svg?seed=" + User.LoginResponse.UserId; - _roomCount = (await hs.GetJoinedRooms()).Count; + try { + _roomCount = (await hs.GetJoinedRooms()).Count; + } + catch { + _roomCount = -1; + } await base.OnInitializedAsync(); } - private async Task RemoveUser() - { + private async Task RemoveUser() { Console.WriteLine(User.ToJson()); RuntimeCache.LoginSessions.Remove(User.AccessToken); StateHasChanged(); } - private async Task SetCurrent() - { + private async Task SetCurrent() { RuntimeCache.LastUsedToken = User.AccessToken; //RuntimeCache.CurrentHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(LocalStorageWrapper.LoginSessions[Token].LoginResponse.HomeServer); await LocalStorageWrapper.SaveToLocalStorage(LocalStorage); await LocalStorageWrapper.InitialiseRuntimeVariables(LocalStorage); StateHasChanged(); } + } \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor index 56131c8..9833c62 100644 --- a/MatrixRoomUtils.Web/Shared/InlineUserItem.razor +++ b/MatrixRoomUtils.Web/Shared/InlineUserItem.razor @@ -4,8 +4,7 @@ @ProfileName
- @if (ChildContent != null) - { + @if (ChildContent != null) { @ChildContent }
@@ -25,15 +24,13 @@ [Parameter] public string? ProfileAvatar { get; set; } = null; - + [Parameter] public string? ProfileName { get; set; } = null; - private static SemaphoreSlim _semaphoreSlim = new(128); - protected override async Task OnInitializedAsync() - { + protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); @@ -41,19 +38,14 @@ var hs = await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure(); - if (User == null) - { - if (UserId == null) - { + if (User == null) { + if (UserId == null) { throw new ArgumentNullException(nameof(UserId)); } User = await hs.GetProfile(UserId); } - else - { - // UserId = User.; - } - + + // UserId = User.; ProfileAvatar ??= RuntimeCache.CurrentHomeServer.ResolveMediaUri(User.AvatarUrl); ProfileName ??= User.DisplayName; diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor index 80fd355..2f83cb2 100644 --- a/MatrixRoomUtils.Web/Shared/LogView.razor +++ b/MatrixRoomUtils.Web/Shared/LogView.razor @@ -1,6 +1,5 @@ @using System.Text -@if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) -{ +@if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) { Logs
@@ -10,11 +9,10 @@
 
 @code {
     StringBuilder _stringBuilder = new();
-    protected override async Task OnInitializedAsync()
-    {
+
+    protected override async Task OnInitializedAsync() {
         await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-        if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging)
-        {
+        if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) {
             Console.WriteLine("Console logging disabled!");
             var _sw = new StringWriter();
             Console.SetOut(_sw);
@@ -22,19 +20,16 @@
             return;
         }
         if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) return;
-        //intecept stdout with textwriter to get logs
+    //intecept stdout with textwriter to get logs
         var sw = new StringWriter(_stringBuilder);
         Console.SetOut(sw);
         Console.SetError(sw);
-        //keep updated
-        int length = 0;
-        Task.Run(async () =>
-        {
-            while (true)
-            {
+    //keep updated
+        var length = 0;
+        Task.Run(async () => {
+            while (true) {
                 await Task.Delay(100);
-                if (_stringBuilder.Length != length)
-                {
+                if (_stringBuilder.Length != length) {
                     StateHasChanged();
                     length = _stringBuilder.Length;
                 }
@@ -43,4 +38,5 @@
         });
         await base.OnInitializedAsync();
     }
+
 }
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/MainLayout.razor b/MatrixRoomUtils.Web/Shared/MainLayout.razor
index cdb1205..317f9e6 100644
--- a/MatrixRoomUtils.Web/Shared/MainLayout.razor
+++ b/MatrixRoomUtils.Web/Shared/MainLayout.razor
@@ -11,8 +11,7 @@
             
             Git
             Matrix
-            @if (showDownload)
-            {
+            @if (showDownload) {
                 Download
             }
         
@@ -24,24 +23,22 @@
 
 
 @code {
-    private bool showDownload { get; set; } = false;
+    private bool showDownload { get; set; }
 
-    protected override async Task OnInitializedAsync()
-    {
+    protected override async Task OnInitializedAsync() {
         using var hc = new HttpClient();
-        var hr = await hc.SendAsync(new(HttpMethod.Head, NavigationManager.ToAbsoluteUri("/MRU-BIN.tar.xz").AbsoluteUri));
+        var hr = await hc.SendAsync(new HttpRequestMessage(HttpMethod.Head, NavigationManager.ToAbsoluteUri("/MRU-BIN.tar.xz").AbsoluteUri));
         showDownload = hr.StatusCode == HttpStatusCode.OK;
 
         await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-        if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging)
-        {
+        if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) {
             Console.WriteLine("Console logging disabled!");
             var sw = new StringWriter();
             Console.SetOut(sw);
             Console.SetError(sw);
         }
-        
-        await base.OnInitializedAsync();
 
+        await base.OnInitializedAsync();
     }
+
 }
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/MainLayout.razor.css b/MatrixRoomUtils.Web/Shared/MainLayout.razor.css
index c865427..01a5066 100644
--- a/MatrixRoomUtils.Web/Shared/MainLayout.razor.css
+++ b/MatrixRoomUtils.Web/Shared/MainLayout.razor.css
@@ -21,20 +21,20 @@ main {
     align-items: center;
 }
 
-    .top-row ::deep a, .top-row ::deep .btn-link {
-        white-space: nowrap;
-        margin-left: 1.5rem;
-        text-decoration: none;
-    }
+.top-row ::deep a, .top-row ::deep .btn-link {
+    white-space: nowrap;
+    margin-left: 1.5rem;
+    text-decoration: none;
+}
 
-    .top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
-        text-decoration: underline;
-    }
+.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
+    text-decoration: underline;
+}
 
-    .top-row ::deep a:first-child {
-        overflow: hidden;
-        text-overflow: ellipsis;
-    }
+.top-row ::deep a:first-child {
+    overflow: hidden;
+    text-overflow: ellipsis;
+}
 
 @media (max-width: 640.98px) {
     .top-row:not(.auth) {
diff --git a/MatrixRoomUtils.Web/Shared/NavMenu.razor b/MatrixRoomUtils.Web/Shared/NavMenu.razor
index 44dd9df..9ddbd84 100644
--- a/MatrixRoomUtils.Web/Shared/NavMenu.razor
+++ b/MatrixRoomUtils.Web/Shared/NavMenu.razor
@@ -61,6 +61,13 @@
         @*          Media locator *@
         @*      *@
         @*  *@
+
+        
+