Add numerous new things
1 files changed, 54 insertions, 3 deletions
diff --git a/MatrixRoomUtils.Web/Pages/DevOptions.razor b/MatrixRoomUtils.Web/Pages/DevOptions.razor
index 0cc38d8..e1b6ac0 100644
--- a/MatrixRoomUtils.Web/Pages/DevOptions.razor
+++ b/MatrixRoomUtils.Web/Pages/DevOptions.razor
@@ -1,6 +1,4 @@
@page "/DevOptions"
-@using MatrixRoomUtils.Web.Shared.IndexComponents
-@using System.Net
@using MatrixRoomUtils.Core.Extensions
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
@@ -10,8 +8,32 @@
<h3>Rory&::MatrixUtils - Developer options</h3>
<hr/>
-<InputCheckbox @bind-Value="@LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers" @oninput="@LogStuff"></InputCheckbox><label> Enable log views</label>
+<InputCheckbox @bind-Value="@LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers" @oninput="@LogStuff"></InputCheckbox><label> Enable log views</label><br/>
+<InputCheckbox @bind-Value="@LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging" @oninput="@LogStuff"></InputCheckbox><label> Enable console logging</label><br/>
+<InputCheckbox @bind-Value="@LocalStorageWrapper.Settings.DeveloperSettings.EnablePortableDevtools" @oninput="@LogStuff"></InputCheckbox><label> Enable portable devtools</label><br/>
+<button @onclick="@DropCaches">Drop caches</button>
+<button @onclick="@RandomiseCacheTimers">Randomise cache timers</button>
+<br/>
+<details open>
+ <summary>View caches</summary>
+ <p>Generic cache:</p>
+ <ul>
+ @foreach (var item in RuntimeCache.GenericResponseCache)
+ {
+ <li>
+ @item.Key: @item.Value.Cache.Count entries<br/>
+ Default expiry: @item.Value.DefaultExpiry<br/>
+ @if (item.Value.Cache.Count > 0)
+ {
+ <p>Earliest expiry: @(item.Value.Cache.Min(x => x.Value.ExpiryTime)) (@string.Format("{0:g}", item.Value.Cache.Min(x => x.Value.ExpiryTime).Value.Subtract(DateTime.Now)) from now)</p>
+ @* <p>Average expiry: @(item.Value.Cache.Average(x => x.Value.ExpiryTime.Value))(@item.Value.Cache.Average(x => x.Value.ExpiryTime).Value.Subtract(DateTime.Now) from now)</p> *@
+ <p>Last expiry: @(item.Value.Cache.Max(x => x.Value.ExpiryTime)) (@string.Format("{0:g}", item.Value.Cache.Max(x => x.Value.ExpiryTime).Value.Subtract(DateTime.Now)) from now)</p>
+ }
+ </li>
+ }
+ </ul>
+</details>
@code {
protected override async Task OnInitializedAsync()
@@ -19,6 +41,14 @@
await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage);
await base.OnInitializedAsync();
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
+ Task.Run(async () =>
+ {
+ while (true)
+ {
+ await Task.Delay(100);
+ StateHasChanged();
+ }
+ });
}
protected async Task LogStuff()
@@ -29,4 +59,25 @@
await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
}
+ protected async Task DropCaches()
+ {
+ RuntimeCache.GenericResponseCache.Clear();
+ RuntimeCache.HomeserverResolutionCache.Clear();
+ await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
+ }
+
+ protected async Task RandomiseCacheTimers()
+ {
+ foreach (var keyValuePair in RuntimeCache.GenericResponseCache)
+ {
+ Console.WriteLine($"Randomising cache timer for {keyValuePair.Key}");
+ foreach (var cacheItem in keyValuePair.Value.Cache)
+ {
+ cacheItem.Value.ExpiryTime = DateTime.Now.AddSeconds(Random.Shared.Next(15, 120));
+ }
+
+ await LocalStorageWrapper.SaveToLocalStorage(LocalStorage);
+ }
+ }
+
}
\ No newline at end of file
|