about summary refs log tree commit diff
path: root/BugMine.Web/Pages/Projects
diff options
context:
space:
mode:
Diffstat (limited to 'BugMine.Web/Pages/Projects')
-rw-r--r--BugMine.Web/Pages/Projects/Index.razor2
-rw-r--r--BugMine.Web/Pages/Projects/Issues/NewIssue.razor15
-rw-r--r--BugMine.Web/Pages/Projects/NewProject.razor28
-rw-r--r--BugMine.Web/Pages/Projects/ViewProject.razor89
4 files changed, 52 insertions, 82 deletions
diff --git a/BugMine.Web/Pages/Projects/Index.razor b/BugMine.Web/Pages/Projects/Index.razor
index 8f46d02..9755dc3 100644
--- a/BugMine.Web/Pages/Projects/Index.razor
+++ b/BugMine.Web/Pages/Projects/Index.razor
@@ -46,7 +46,7 @@ else {
 
         int count = 0;
         SemaphoreSlim semaphore = new(16, 16);
-        await foreach (var project in Client.GetProjects(semaphore)) {
+        await foreach (var project in Client.GetProjects(semaphore, ignoreInvalidBoards: true)) {
             Projects ??= [];
             Projects.Add(project);
             if(count++ <= 250 || count % 4 == 0)
diff --git a/BugMine.Web/Pages/Projects/Issues/NewIssue.razor b/BugMine.Web/Pages/Projects/Issues/NewIssue.razor
new file mode 100644
index 0000000..159e20d
--- /dev/null
+++ b/BugMine.Web/Pages/Projects/Issues/NewIssue.razor
@@ -0,0 +1,15 @@
+@page "/Projects/{ProjectSlug}/Issues/New"
+<h3>New issue</h3>
+
+<ProjectContainer ProjectSlug="@ProjectSlug" ProjectContext="@ProjectContext">
+    <h1>Hi from NewIssue!</h1>
+</ProjectContainer>
+
+@code {
+
+    [Parameter]
+    public string ProjectSlug { get; set; } = null!;
+
+    public ProjectContainer.ProjectContainerContext? ProjectContext { get; set; } = new();
+
+}
\ No newline at end of file
diff --git a/BugMine.Web/Pages/Projects/NewProject.razor b/BugMine.Web/Pages/Projects/NewProject.razor
index 00b7b21..f8c7dfd 100644
--- a/BugMine.Web/Pages/Projects/NewProject.razor
+++ b/BugMine.Web/Pages/Projects/NewProject.razor
@@ -1,5 +1,6 @@
 @page "/Projects/New"
 @using ArcaneLibs.Extensions
+@using LibMatrix
 <h3>New project</h3>
 
 <span>Project name: </span>
@@ -20,10 +21,25 @@
     <br/>
 }
 
-<LinkButton OnClick="@CreateProject">Create project</LinkButton>
+@if (!_busy) {
+    <LinkButton OnClick="@CreateProject">Create project</LinkButton>
+}
+else {
+    <p>Powering up the framework... <SimpleSpinner/></p>
+}
 
 @code {
 
+    private bool _busy = false;
+    
+    private bool Busy {
+        get => _busy;
+        set {
+            _busy = value;
+            StateHasChanged();
+        }
+    }
+    
     private BugMineClient? Client { get; set; }
 
     private readonly ProjectInfo _request = new();
@@ -39,9 +55,15 @@
         if (Client == null) {
             return;
         }
+        Busy = true;
+        try {
+            var proj = await Client.CreateProject(_request);
+            NavigationManager.NavigateTo($"/Projects/{proj.ProjectSlug}/");
 
-        var proj = await Client.CreateProject(_request);
-        NavigationManager.NavigateTo($"/Projects/{proj.ProjectSlug}/");
+        }
+        catch (MatrixException e) {
+            
+        }
     }
 
 }
\ No newline at end of file
diff --git a/BugMine.Web/Pages/Projects/ViewProject.razor b/BugMine.Web/Pages/Projects/ViewProject.razor
index ec10d1c..91cc4d0 100644
--- a/BugMine.Web/Pages/Projects/ViewProject.razor
+++ b/BugMine.Web/Pages/Projects/ViewProject.razor
@@ -5,48 +5,30 @@
 
 <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>
+<ProjectContainer ProjectSlug="@ProjectSlug" ProjectContext="@ProjectContext" Loaded="@OnProjectLoaded">
+    <h1>Hi from ViewProject!</h1>
+    <h1>@ProjectContext!.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) {
+        @foreach (var issue in Issues) {
             <pre>@issue.Data.RawContent.ToJson()</pre>
         }
     }
-}
+</ProjectContainer>
 
 @code {
     private string? _progress = "loading";
 
+    public ProjectContainer.ProjectContainerContext? ProjectContext { get; set; } = new();
+
     [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 {
@@ -57,64 +39,15 @@ else {
         }
     }
 
-    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;
-        }
-        
+    protected async Task OnProjectLoaded() {
         Progress = "loading-issues";
-        await foreach (var issue in Project.GetIssues()) {
+        await foreach (var issue in ProjectContext.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();
-    }
-
-}
-
+}
\ No newline at end of file