about summary refs log tree commit diff
path: root/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-05-14 17:49:09 +0200
committerRory& <root@rory.gay>2024-05-14 17:49:09 +0200
commit41c5a84dacfd036b8d8f01f72226ac5a519995e3 (patch)
treea4bfc76541692cbbb0fc18f34463cf31a57440f5 /MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
parentImprove the heatmap layout (diff)
downloadMatrixUtils-41c5a84dacfd036b8d8f01f72226ac5a519995e3.tar.xz
Organise tools somewhat, set proper icons for nav menu
Diffstat (limited to 'MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor')
-rw-r--r--MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor52
1 files changed, 52 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor b/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
new file mode 100644

index 0000000..841552e --- /dev/null +++ b/MatrixUtils.Web/Pages/Tools/Debug/LeaveRoom.razor
@@ -0,0 +1,52 @@ +@page "/Tools/LeaveRoom" +@using System.Collections.ObjectModel +<h3>Leave room</h3> +<hr/> +<span>Room ID: </span> +<InputText @bind-Value="@RoomId"></InputText> +<br/> +<LinkButton OnClick="@Leave">Leave</LinkButton> +<br/><br/> +@foreach (var line in Log) { + <p>@line</p> +} +@code { + AuthenticatedHomeserverGeneric? hs { get; set; } + ObservableCollection<string> Log { get; set; } = new ObservableCollection<string>(); + [Parameter, SupplyParameterFromQuery(Name = "roomId")] + public string? RoomId { get; set; } + + protected override async Task OnInitializedAsync() { + hs = await RMUStorage.GetCurrentSessionOrNavigate(); + if (hs is null) return; + Log.CollectionChanged += (sender, args) => StateHasChanged(); + + StateHasChanged(); + Console.WriteLine("Rerendered!"); + await base.OnInitializedAsync(); + } + + private async Task Leave() { + if(string.IsNullOrWhiteSpace(RoomId)) return; + var room = hs.GetRoom(RoomId); + Log.Add("Got room object..."); + try { + await room.LeaveAsync(); + Log.Add("Left room!"); + } + catch (Exception e) { + Log.Add(e.ToString()); + } + + try { + await room.ForgetAsync(); + Log.Add("Forgot room!"); + } + catch (Exception e) { + Log.Add(e.ToString()); + } + + Log.Add("Done!"); + } + +} \ No newline at end of file