@page "/Labs/DMSpace/Setup" @using LibMatrix @using LibMatrix.Responses @using MatrixUtils.Abstractions @using MatrixUtils.LibDMSpace @using MatrixUtils.LibDMSpace.StateEvents @using MatrixUtils.Web.Pages.Labs.DMSpace.DMSpaceStages @using System.Text.Json.Serialization

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 DMSpace? DMSpaceRootPage { get; set; } protected override async Task OnInitializedAsync() { if (NavigationManager.Uri.Contains("?stage=")) { NavigationManager.NavigateTo(NavigationManager.Uri.Replace("stage=", ""), true); //"/User/DMSpace/Setup" } DMSpaceRootPage = this; SetupData.Homeserver ??= await RMUStorage.GetCurrentSessionOrNavigate(); if (SetupData.Homeserver is null) return; try { SetupData.DmSpaceConfiguration = await SetupData.Homeserver.GetAccountDataAsync("gay.rory.dm_space"); var room = SetupData.Homeserver.GetRoom(SetupData.DmSpaceConfiguration.DMSpaceId); await room.GetStateAsync(DMSpaceInfo.EventId); Stage = 1; } catch (MatrixException e) { if (e.ErrorCode is "M_NOT_FOUND" or "M_FORBIDDEN") { Stage = 0; SetupData.DmSpaceConfiguration = new(); } else throw; } finally { StateHasChanged(); } await base.OnInitializedAsync(); } protected override async Task OnParametersSetAsync() { StateHasChanged(); await base.OnParametersSetAsync(); } public DMSpaceSetupData SetupData { get; set; } = new(); public class DMSpaceSetupData { public AuthenticatedHomeserverGeneric? Homeserver { get; set; } public DMSpaceConfiguration? DmSpaceConfiguration { get; set; } public DMSpaceInfo? DmSpaceInfo { get; set; } = new(); public Dictionary? Spaces; public Dictionary>? DMRooms; public RoomInfo? DMSpaceRoomInfo { get; set; } public class UserProfileWithId : UserProfileResponse { [JsonIgnore] public string Id { get; set; } } } }