From 1fea7b0aa6ffbd7d87a7d23ef9c642c109697758 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 16 May 2024 11:48:35 +0200 Subject: Add basic issues, abstract project loading to component in web --- BugMine.Web/Pages/Projects/ViewProject.razor | 89 ++++------------------------ 1 file changed, 11 insertions(+), 78 deletions(-) (limited to 'BugMine.Web/Pages/Projects/ViewProject.razor') 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 @@ -@if (Client is null) { -

Authenticating

-} -else if (Project is null) { - @if (Progress == "loading") { -

Loading project

- } - else if (Progress == "not-in-room") { -

You are not in the project room.

-

You must join before you can view or interact with this project.

- Attempt to join - } -} -else { -

@Project.Info.Name

+ +

Hi from ViewProject!

+

@ProjectContext!.Project!.Info.Name

- @if (Constants.Debug) { -

Debug, beware: here be dragons!

- Dispose room - } - @if (Progress == "loading-issues") {

Loading issues, got @(Issues?.Count ?? 0) so far...

} + @*

@Project.Description

*@ @if (Issues != null) { - @foreach(var issue in Issues) { + @foreach (var issue in Issues) {
@issue.Data.RawContent.ToJson()
} } -} +
@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? 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(); 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 -- cgit 1.5.1