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<string>
<pre id="@Id" class="@CssClass" @onkeyup="Callback" contenteditable="true">@CurrentValue</pre>
+
@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 @@
<span style="position: relative; top: -5px;">@ProfileName</span>
<div style="display: inline-block;">
- @if (ChildContent != null)
- {
+ @if (ChildContent != null) {
@ChildContent
}
</div>
@@ -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) {
<u>Logs</u>
<br/>
<pre>
@@ -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 @@
<PortableDevTools></PortableDevTools>
<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>
- @if (showDownload)
- {
+ @if (showDownload) {
<a href="/MRU.tar.xz" target="_blank">Download</a>
}
</div>
@@ -24,24 +23,22 @@
</div>
@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 @@
@* <span class="oi oi-plus" aria-hidden="true"></span> Media locator *@
@* </NavLink> *@
@* </div> *@
+
+ <div class="nav-item px-3">
+ <NavLink class="nav-link" href="HSAdmin">
+ <span class="oi oi-plus" aria-hidden="true"></span> HS Admin
+ </NavLink>
+ </div>
+
<div class="nav-item px-3">
<h5 style="margin-left: 1em;">MRU</h5>
<hr style="margin-bottom: 0em;"/>
@@ -78,9 +85,6 @@
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
- private void ToggleNavMenu()
- {
- collapseNavMenu = !collapseNavMenu;
- }
+ private void ToggleNavMenu() => collapseNavMenu = !collapseNavMenu;
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/NavMenu.razor.css b/MatrixRoomUtils.Web/Shared/NavMenu.razor.css
index 604b7a1..447f2df 100644
--- a/MatrixRoomUtils.Web/Shared/NavMenu.razor.css
+++ b/MatrixRoomUtils.Web/Shared/NavMenu.razor.css
@@ -4,7 +4,7 @@
.top-row {
height: 3.5rem;
- background-color: rgba(0,0,0,0.4);
+ background-color: rgba(0, 0, 0, 0.4);
}
.navbar-brand {
@@ -23,30 +23,30 @@
padding-bottom: 0.5rem;
}
- .nav-item:first-of-type {
- padding-top: 1rem;
- }
+.nav-item:first-of-type {
+ padding-top: 1rem;
+}
- .nav-item:last-of-type {
- padding-bottom: 1rem;
- }
+.nav-item:last-of-type {
+ padding-bottom: 1rem;
+}
- .nav-item ::deep a {
- color: #d7d7d7;
- border-radius: 4px;
- height: 3rem;
- display: flex;
- align-items: center;
- line-height: 3rem;
- }
+.nav-item ::deep a {
+ color: #d7d7d7;
+ border-radius: 4px;
+ height: 3rem;
+ display: flex;
+ align-items: center;
+ line-height: 3rem;
+}
.nav-item ::deep a.active {
- background-color: rgba(255,255,255,0.25);
+ background-color: rgba(255, 255, 255, 0.25);
color: white;
}
.nav-item ::deep a:hover {
- background-color: rgba(255,255,255,0.1);
+ background-color: rgba(255, 255, 255, 0.1);
color: white;
}
@@ -59,7 +59,7 @@
/* Never collapse the sidebar for wide screens */
display: block;
}
-
+
.nav-scrollable {
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
diff --git a/MatrixRoomUtils.Web/Shared/PortableDevTools.razor b/MatrixRoomUtils.Web/Shared/PortableDevTools.razor
index 84e7791..ffd7082 100644
--- a/MatrixRoomUtils.Web/Shared/PortableDevTools.razor
+++ b/MatrixRoomUtils.Web/Shared/PortableDevTools.razor
@@ -1,9 +1,7 @@
-
-@if (Enabled)
-{
+@if (Enabled) {
<a href="/DevOptions">Portable devtools (enabled)</a>
<div id="PortableDevTools" style="position: fixed; bottom: 0; right: 0; min-width: 200px; min-height: 100px; background: #0002;" draggable>
- <p>Cache size: @RuntimeCache.GenericResponseCache.Sum(x=>x.Value.Cache.Count)</p>
+ <p>Cache size: @RuntimeCache.GenericResponseCache.Sum(x => x.Value.Cache.Count)</p>
</div>
}
else {
@@ -13,19 +11,16 @@ else {
@code {
private bool Enabled { get; set; } = LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools;
- protected override async Task OnInitializedAsync()
- {
- // if(!RuntimeCache.WasLoaded)
- // await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
- // StateHasChanged();
- Task.Run(async () =>
- {
- while (true)
- {
+ protected override async Task OnInitializedAsync() =>
+ // if(!RuntimeCache.WasLoaded)
+ // await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
+ // StateHasChanged();
+ Task.Run(async () => {
+ while (true) {
await Task.Delay(100);
Enabled = LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools;
StateHasChanged();
}
});
- }
+
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
index fb28c3c..f58ab3a 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor
@@ -1,18 +1,15 @@
-@using MatrixRoomUtils.Core.Authentication
-@using System.Text.Json
@using MatrixRoomUtils.Core.Extensions
+@using System.Text.Json
<div class="roomListItem" style="background-color: #ffffff11; border-radius: 25px; margin: 8px; width: fit-Content; @(hasDangerousRoomVersion ? "border: red 4px solid;" : hasOldRoomVersion ? "border: #FF0 1px solid;" : "")">
- @if (ShowOwnProfile)
- {
- <img class="imageUnloaded @(string.IsNullOrWhiteSpace(profileAvatar) ? "" : "imageLoaded")" style="@(ChildContent != null ? "vertical-align: baseline;":"") width: 32px; height: 32px; border-radius: 50%; @(hasCustomProfileAvatar ? "border-color: red; border-width: 3px; border-style: dashed;" : "")" src="@(profileAvatar ?? "/icon-192.png")" @onload="Callback"/>
+ @if (ShowOwnProfile) {
+ <img class="imageUnloaded @(string.IsNullOrWhiteSpace(profileAvatar) ? "" : "imageLoaded")" style="@(ChildContent != null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%; @(hasCustomProfileAvatar ? "border-color: red; border-width: 3px; border-style: dashed;" : "")" src="@(profileAvatar ?? "/icon-192.png")" @onload="Callback"/>
<span style="vertical-align: middle; margin-right: 8px; border-radius: 75px; @(hasCustomProfileName ? "background-color: red;" : "")">@(profileName ?? "Loading...")</span>
<span style="vertical-align: middle; padding-right: 8px; padding-left: 0px;">-></span>
}
- <img style="@(ChildContent != null ? "vertical-align: baseline;":"") width: 32px; height: 32px; border-radius: 50%;" src="@roomIcon"/>
+ <img style="@(ChildContent != null ? "vertical-align: baseline;" : "") width: 32px; height: 32px; border-radius: 50%;" src="@roomIcon"/>
<div style="display: inline-block;">
- <span style="vertical-align: middle; padding-right: 8px;">@roomName</span>
- @if (ChildContent != null)
- {
+ <span style="vertical-align: middle; padding-right: 8px;">@RoomName</span>
+ @if (ChildContent != null) {
@ChildContent
}
</div>
@@ -33,103 +30,86 @@
[Parameter]
public bool ShowOwnProfile { get; set; } = false;
- private string roomName { get; set; } = "Loading...";
+ [Parameter]
+ public string? RoomName { get; set; }
+
private string? roomIcon { get; set; } = "/icon-192.png";
private string? profileAvatar { get; set; }
private string? profileName { get; set; }
private bool hasCustomProfileAvatar { get; set; } = false;
private bool hasCustomProfileName { get; set; } = false;
-
+
private bool hasOldRoomVersion { get; set; } = false;
private bool hasDangerousRoomVersion { get; set; } = false;
-
-
+
private static SemaphoreSlim _semaphoreSlim = new(128);
- protected override async Task OnInitializedAsync()
- {
+ protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
-
+
await _semaphoreSlim.WaitAsync();
var hs = RuntimeCache.CurrentHomeServer; //await new AuthenticatedHomeServer(RuntimeCache.CurrentHomeServer.UserId, RuntimeCache.CurrentHomeServer.AccessToken, RuntimeCache.CurrentHomeServer.HomeServerDomain).Configure();
-
- if (Room == null)
- {
- if (RoomId == null)
- {
+
+ if (Room == null) {
+ if (RoomId == null) {
throw new ArgumentNullException(nameof(RoomId));
}
Room = await hs.GetRoom(RoomId);
}
- else
- {
+ else {
RoomId = Room.RoomId;
}
- roomName = await Room.GetNameAsync() ?? "Unnamed room: " + RoomId;
+ RoomName ??= await Room.GetNameAsync() ?? "Unnamed room: " + RoomId;
var ce = await Room.GetCreateEventAsync();
- if (ce != null)
- {
- if (int.TryParse(ce.RoomVersion, out int rv) && rv < 10)
- {
+ if (ce != null) {
+ if (int.TryParse(ce.RoomVersion, out var rv) && rv < 10) {
hasOldRoomVersion = true;
}
- if (new[] { "1", "8" }.Contains(ce.RoomVersion))
- {
+ if (new[] { "1", "8" }.Contains(ce.RoomVersion)) {
hasDangerousRoomVersion = true;
- roomName = "Dangerous room: " + roomName;
+ RoomName = "Dangerous room: " + RoomName;
}
}
-
var state = await Room.GetStateAsync("m.room.avatar");
- if (state != null)
- {
- try
- {
+ if (state != null) {
+ try {
var url = state.Value.GetProperty("url").GetString();
- if (url != null)
- {
+ if (url != null) {
roomIcon = hs.ResolveMediaUri(url);
Console.WriteLine($"Got avatar for room {RoomId}: {roomIcon} ({url})");
}
}
- catch (InvalidOperationException e)
- {
+ catch (InvalidOperationException e) {
Console.WriteLine($"Failed to get avatar for room {RoomId}: {e.Message}\n{state.Value.ToJson()}");
}
}
- if (ShowOwnProfile)
- {
- var profile = await hs.GetProfile(hs.UserId, debounce: true);
+ if (ShowOwnProfile) {
+ var profile = await hs.GetProfile(hs.UserId, true);
var memberState = await Room.GetStateAsync("m.room.member", hs.UserId);
- if (memberState.HasValue)
- {
+ if (memberState.HasValue) {
memberState.Value.TryGetProperty("avatar_url", out var _avatar);
- if (_avatar.ValueKind == JsonValueKind.String)
- {
+ if (_avatar.ValueKind == JsonValueKind.String) {
hasCustomProfileAvatar = _avatar.GetString() != profile.AvatarUrl;
profileAvatar = hs.ResolveMediaUri(_avatar.GetString());
}
- else
- {
+ else {
profileAvatar = "/icon-192.png";
}
memberState.Value.TryGetProperty("displayname", out var _name);
- if (_name.ValueKind == JsonValueKind.String)
- {
+ if (_name.ValueKind == JsonValueKind.String) {
hasCustomProfileName = _name.GetString() != profile.DisplayName;
profileName = _name.GetString();
// Console.WriteLine($"{profile.DisplayName} - {_name.GetString()}: {hasCustomProfileName}");
}
- else
- {
+ else {
profileName = "Unnamed user";
}
}
@@ -139,9 +119,6 @@
await LocalStorageWrapper.SaveCacheToLocalStorage(LocalStorage);
}
- private void Callback(ProgressEventArgs obj)
- {
- Console.WriteLine("prog: " + obj.ToJson(indent: false));
- }
+ private void Callback(ProgressEventArgs obj) => Console.WriteLine("prog: " + obj.ToJson(false));
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/RoomListItem.razor.css b/MatrixRoomUtils.Web/Shared/RoomListItem.razor.css
index 8b9a9f6..da22d38 100644
--- a/MatrixRoomUtils.Web/Shared/RoomListItem.razor.css
+++ b/MatrixRoomUtils.Web/Shared/RoomListItem.razor.css
@@ -5,6 +5,6 @@
/*}*/
.imageLoaded {
- opacity: 1;
- scale: 1;
- }
\ No newline at end of file
+ opacity: 1;
+ scale: 1;
+}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor
index 4d90c57..42a5f64 100644
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor
+++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor
@@ -1,9 +1,8 @@
@using MatrixRoomUtils.Core.Extensions
<table>
- @foreach(var i in Items.Keys)
- {
+ @foreach (var i in Items.Keys) {
var key = i;
- <input value="@Items[key]" @oninput="(obj) => inputChanged(obj, key)">
+ <input value="@Items[key]" @oninput="obj => inputChanged(obj, key)">
<button @onclick="() => { Items.Remove(key); ItemsChanged.InvokeAsync(); }">Remove</button>
<br/>
}
@@ -11,28 +10,26 @@
<button @onclick="() => { Items.Add(string.Empty, default); ItemsChanged.InvokeAsync(); }">Add</button>
@code {
-
+
[Parameter]
public Dictionary<string, object> Items { get; set; } = new();
- [Parameter, EditorRequired]
+ [Parameter]
+ [EditorRequired]
public EventCallback ItemsChanged { get; set; }
[Parameter]
- public Func<string,string>? KeyFormatter { get; set; }
-
+ public Func<string, string>? KeyFormatter { get; set; }
+
[Parameter]
public Action? OnFocusLost { get; set; }
-
- protected override Task OnInitializedAsync()
- {
+ protected override Task OnInitializedAsync() {
Console.WriteLine($"DictionaryEditor initialized with {Items.Count} items: {Items.ToJson()}");
return base.OnInitializedAsync();
}
- private void inputChanged(ChangeEventArgs obj, string key)
- {
+ private void inputChanged(ChangeEventArgs obj, string key) {
Console.WriteLine($"StringListEditor inputChanged {key} {obj.Value}");
Items[key] = obj.Value.ToString();
ItemsChanged.InvokeAsync();
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
index 702d41e..d17d0de 100644
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
+++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
@@ -1,35 +1,29 @@
@inject IJSRuntime JsRuntime
-@if (isVisible)
-{
+@if (isVisible) {
<input autofocus type="@(IsPassword ? "password" : "text")" @bind="Value" @onfocusout="() => { isVisible = false; ValueChanged.InvokeAsync(Value); }" @ref="elementToFocus"/>
}
-else
-{
- <span tabindex="0" style="border-bottom: #ccc solid 1px; height: 1.4em; display: inline-block; @(string.IsNullOrEmpty(Value) ? "min-width: 50px;" : "")" @onfocusin="() => isVisible = true">@(Formatter?.Invoke(Value) ?? (IsPassword ? string.Join("", Value.Select(x=>'*')) : Value))</span>
+else {
+ <span tabindex="0" style="border-bottom: #ccc solid 1px; height: 1.4em; display: inline-block; @(string.IsNullOrEmpty(Value) ? "min-width: 50px;" : "")" @onfocusin="() => isVisible = true">@(Formatter?.Invoke(Value) ?? (IsPassword ? string.Join("", Value.Select(x => '*')) : Value))</span>
}
@code {
[Parameter]
public string Value { get; set; }
-
+
[Parameter]
public bool IsPassword { get; set; } = false;
-
+
[Parameter]
public EventCallback<string> ValueChanged { get; set; }
-
+
[Parameter]
public Func<string?, string>? Formatter { get; set; }
-
private bool isVisible { get; set; } = false;
private ElementReference elementToFocus;
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus);
- }
+ protected override async Task OnAfterRenderAsync(bool firstRender) => await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus);
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor
index fe3a938..2bd6ed5 100644
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor
+++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor
@@ -1,5 +1,4 @@
-@for (int i = 0; i < Items.Count; i++)
-{
+@for (var i = 0; i < Items.Count; i++) {
var self = i;
<button @onclick="() => { Items.RemoveAt(self); ItemsChanged.InvokeAsync(); }">Remove</button>
<FancyTextBox Value="@Items[self]" ValueChanged="@(obj => inputChanged(obj, self))"/>
@@ -10,19 +9,18 @@
@code {
[Parameter]
- public List<string> Items { get; set; } = new List<string>();
+ public List<string> Items { get; set; } = new();
- [Parameter, EditorRequired]
+ [Parameter]
+ [EditorRequired]
public EventCallback ItemsChanged { get; set; }
- protected override Task OnInitializedAsync()
- {
+ protected override Task OnInitializedAsync() {
Console.WriteLine($"StringListEditor initialized with {Items.Count} items: {string.Join(",", Items)}");
return base.OnInitializedAsync();
}
- private void inputChanged(string obj, int i)
- {
+ private void inputChanged(string obj, int i) {
Console.WriteLine($"StringListEditor inputChanged {i} {obj}");
Items[i] = obj;
ItemsChanged.InvokeAsync();
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor
index 49a363d..1a38e26 100644
--- a/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor
+++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor
@@ -59,12 +59,14 @@
</style>
@code {
+
[Parameter]
public RenderFragment? ChildContent { get; set; }
-
+
[Parameter]
public bool Value { get; set; }
+
[Parameter]
public EventCallback<bool> ValueChanged { get; set; }
-
+
}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
index 3803d38..4fb5596 100644
--- a/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
+++ b/MatrixRoomUtils.Web/Shared/TimelineComponents/TimelineMemberItem.razor
@@ -1,33 +1,25 @@
@using MatrixRoomUtils.Core.Extensions
-@if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "ban")
-{
+@if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "ban") {
<i>@Event.StateKey was banned</i>
}
-else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "invite")
-{
+else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "invite") {
<i>@Event.StateKey was invited</i>
}
-else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "join")
-{
- @if (Event.ReplacesState != null)
- {
+else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "join") {
+ @if (Event.ReplacesState != null) {
<i>@Event.StateKey changed their display name to @(Event.ContentAsJsonNode["displayname"]!.GetValue<string>())</i>
}
- else
- {
+ else {
<i><InlineUserItem UserId="@Event.StateKey"></InlineUserItem> joined</i>
}
}
-else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "leave")
-{
+else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "leave") {
<i>@Event.StateKey left</i>
}
-else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "knock")
-{
+else if (Event.ContentAsJsonNode["membership"]!.GetValue<string>() == "knock") {
<i>@Event.StateKey knocked</i>
}
-else
-{
+else {
<i>@Event.StateKey has an unknown state:</i>
<pre>
@Event.ToJson()
diff --git a/MatrixRoomUtils.Web/Shared/UserListItem.razor b/MatrixRoomUtils.Web/Shared/UserListItem.razor
index d357b0d..43c71ab 100644
--- a/MatrixRoomUtils.Web/Shared/UserListItem.razor
+++ b/MatrixRoomUtils.Web/Shared/UserListItem.razor
@@ -4,8 +4,7 @@
<span style="vertical-align: middle; margin-right: 8px; border-radius: 75px;">@profileName</span>
<div style="display: inline-block;">
- @if (ChildContent != null)
- {
+ @if (ChildContent != null) {
@ChildContent
}
</div>
@@ -26,11 +25,9 @@
private string? profileAvatar { get; set; } = "/icon-192.png";
private string? profileName { get; set; } = "Loading...";
-
private static SemaphoreSlim _semaphoreSlim = new(128);
- protected override async Task OnInitializedAsync()
- {
+ protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
@@ -38,19 +35,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;
|