@page "/User/DMSpace/Setup" @using LibMatrix.Homeservers @using LibMatrix @using MatrixUtils.LibDMSpace @using MatrixUtils.LibDMSpace.StateEvents @using MatrixUtils.Web.Pages.User.DMSpaceStages

DM Space Management


@switch (Stage) { case -1:

Initialising...

break; case 0: break; case 1: break; case 2: break; case 3: break; default:

Stage is unknown value: @Stage!

break; }
@code { private int _stage = -1; [Parameter, SupplyParameterFromQuery(Name = "stage")] public int Stage { get => _stage; set { _stage = value; Console.WriteLine($"Stage is now {value}"); StateHasChanged(); } } public AuthenticatedHomeserverGeneric? Homeserver { get; set; } public DMSpaceConfiguration? DmSpaceConfiguration { get; set; } [Parameter] public DMSpace? DmSpace { get; set; } protected override async Task OnInitializedAsync() { if (NavigationManager.Uri.Contains("?stage=")) { NavigationManager.NavigateTo("/User/DMSpace", true); } DmSpace = this; Homeserver ??= await RMUStorage.GetCurrentSessionOrNavigate(); if (Homeserver is null) return; try { DmSpaceConfiguration = await Homeserver.GetAccountDataAsync("gay.rory.dm_space"); var room = Homeserver.GetRoom(DmSpaceConfiguration.DMSpaceId); await room.GetStateAsync(DMSpaceInfo.EventId); Stage = 1; } catch (MatrixException e) { if (e.ErrorCode == "M_NOT_FOUND") { Stage = 0; DmSpaceConfiguration = new(); } else throw; } catch (Exception e) { throw; } finally { StateHasChanged(); } await base.OnInitializedAsync(); } protected override async Task OnParametersSetAsync() { StateHasChanged(); await base.OnParametersSetAsync(); } }