blob: 37516290c5d03e0667dd5f9492eaba2573b9ad02 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
@page "/User/DMSpace/Setup"
@using LibMatrix.Homeservers
@using LibMatrix
@using MatrixUtils.LibDMSpace
@using MatrixUtils.LibDMSpace.StateEvents
@using MatrixUtils.Web.Pages.User.DMSpaceStages
<h3>DM Space Management</h3>
<hr/>
<CascadingValue Value="@DmSpace">
@switch (Stage) {
case -1:
<p>Initialising...</p>
break;
case 0:
<DMSpaceStage0/>
break;
case 1:
<DMSpaceStage1/>
break;
case 2:
<DMSpaceStage2/>
break;
case 3:
<DMSpaceStage3/>
break;
default:
<p>Stage is unknown value: @Stage!</p>
break;
}
</CascadingValue>
@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<DMSpaceConfiguration>("gay.rory.dm_space");
var room = Homeserver.GetRoom(DmSpaceConfiguration.DMSpaceId);
await room.GetStateAsync<object>(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();
}
}
|