blob: ec10d1c792f5469e70de0c4a9be0dfe9fcbf2362 (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
@page "/Projects/{ProjectSlug}/"
@using LibMatrix
@using BugMine.Web.Classes.Exceptions
@using ArcaneLibs.Extensions
<ProgressLog ></ProgressLog>
@if (Client is null) {
<p>Authenticating</p>
}
else if (Project is null) {
@if (Progress == "loading") {
<p>Loading project <SimpleSpinner/></p>
}
else if (Progress == "not-in-room") {
<p>You are not in the project room.</p>
<p>You must join before you can view or interact with this project.</p>
<LinkButton OnClick="TryJoin">Attempt to join</LinkButton>
}
}
else {
<h1>@Project.Info.Name</h1>
@if (Constants.Debug) {
<p>Debug, beware: here be dragons!</p>
<LinkButton OnClick="@Project.Room.PermanentlyBrickRoomAsync">Dispose room</LinkButton>
}
@if (Progress == "loading-issues") {
<p>Loading issues, got @(Issues?.Count ?? 0) so far... <SimpleSpinner/></p>
}
@* <p>@Project.Description</p> *@
@if (Issues != null) {
@foreach(var issue in Issues) {
<pre>@issue.Data.RawContent.ToJson()</pre>
}
}
}
@code {
private string? _progress = "loading";
[Parameter]
public string ProjectSlug { get; set; } = null!;
private BugMineClient? Client { get; set; }
private BugMineProject? Project { get; set; }
private List<BugMineIssue>? Issues { get; set; }
private string? Progress {
get => _progress;
set {
_progress = value;
StateHasChanged();
}
}
protected override async Task OnInitializedAsync() {
Client ??= await BugMineStorage.GetCurrentSessionOrNavigate();
if (Client == null) {
return;
}
Progress = "loading";
StateHasChanged();
try {
Project = await Client.GetProject(ProjectSlug);
}
catch (MatrixException e) {
if (e.ErrorCode == BugMineException.ErrorCodes.UserNotInRoom) {
Progress = "not-in-room";
StateHasChanged();
return;
}
throw;
}
Progress = "loading-issues";
await foreach (var issue in Project.GetIssues()) {
Issues ??= new List<BugMineIssue>();
Issues.Add(issue);
StateHasChanged();
}
StateHasChanged();
}
private async Task TryJoin() {
var room = await Client.ResolveProjectSlug(ProjectSlug);
bool success = false;
while (!success) {
try {
await room.JoinAsync();
if (!string.IsNullOrWhiteSpace(room.RoomId)) {
success = true;
}
else {
await Task.Delay(1000);
}
}
catch (MatrixException e) {
// if (e.ErrorCode == MatrixException.ErrorCodes.) {
// await Task.Delay(1000);
// continue;
// }
throw;
}
}
await OnInitializedAsync();
}
}
|