diff options
author | Rory& <root@rory.gay> | 2024-01-29 10:15:27 +0100 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-01-29 10:15:27 +0100 |
commit | 3e6a73599bb58161c08d8675ea23ee6c82c6675c (patch) | |
tree | f3c0d1e797a77ed5993478d742751d386e004fb7 /MatrixUtils.Web/Pages/Tools | |
parent | Room member migrations (diff) | |
download | MatrixUtils-3e6a73599bb58161c08d8675ea23ee6c82c6675c.tar.xz |
Room list fixes, migration fix, update available handler
Diffstat (limited to 'MatrixUtils.Web/Pages/Tools')
-rw-r--r-- | MatrixUtils.Web/Pages/Tools/Index.razor (renamed from MatrixUtils.Web/Pages/Tools/ToolsIndex.razor) | 2 | ||||
-rw-r--r-- | MatrixUtils.Web/Pages/Tools/LeaveRoom.razor | 56 |
2 files changed, 58 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Pages/Tools/ToolsIndex.razor b/MatrixUtils.Web/Pages/Tools/Index.razor index f4092d7..f1e04a3 100644 --- a/MatrixUtils.Web/Pages/Tools/ToolsIndex.razor +++ b/MatrixUtils.Web/Pages/Tools/Index.razor @@ -6,3 +6,5 @@ <a href="/Tools/MassRoomJoin">Join room across all session</a><br/> <a href="/Tools/MediaLocator">Locate lost media</a><br/> <a href="/Tools/SpaceDebug">Debug space relationships</a><br/> +<a href="/Tools/MigrateRoom">Migrate users from a split room to a new room</a><br/> +<a href="/Tools/LeaveRoom">Leave room by ID</a><br/> diff --git a/MatrixUtils.Web/Pages/Tools/LeaveRoom.razor b/MatrixUtils.Web/Pages/Tools/LeaveRoom.razor new file mode 100644 index 0000000..b5df05f --- /dev/null +++ b/MatrixUtils.Web/Pages/Tools/LeaveRoom.razor @@ -0,0 +1,56 @@ +@page "/Tools/LeaveRoom" +@using System.Diagnostics +@using ArcaneLibs.Extensions +@using LibMatrix.Homeservers +@using LibMatrix.RoomTypes +@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 |