Skip to content

Commit

Permalink
got new paint session navigation working
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed May 6, 2024
1 parent f8b792b commit d899ba9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
13 changes: 4 additions & 9 deletions src/DrawTogether/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@
<AuthorizeView>
<Authorized>
<div class="nav-item px-3">
<button class="nav-link" @onclick="Handler">
<span class="bi bi-pencil-fill-nav-menu" aria-hidden="true"></span> New Drawing
</button>>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Account/Manage">
<span class="bi bi-person-fill-nav-menu" aria-hidden="true"></span> @context.User.Identity?.Name
</NavLink>
<NavLink class="nav-link" href="NewPaint">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> New Drawing
</NavLink>>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Account/Manage">
Expand Down Expand Up @@ -92,7 +87,7 @@
private void Handler()
{
var newGuid = GetNewGuid();
NavigationManager.NavigateTo($"paint/{newGuid}");
NavigationManager.NavigateTo($"paint/{newGuid}", true);
}

}
1 change: 1 addition & 0 deletions src/DrawTogether/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// no active paint sessions right now, would you like to start one?
<div class="center">
<strong>No active sessions right now - would you like to make one?</strong>
<NavLink href="/NewPaint">Start new paint session.</NavLink>
</div>
}
else
Expand Down
12 changes: 12 additions & 0 deletions src/DrawTogether/Components/Pages/NewPaint.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@page "/NewPaint"
@inject NavigationManager NavigationManager

@code {
protected override Task OnInitializedAsync()
{
// navigate to /paint/Guid.NewGuid()
NavigationManager.NavigateTo($"/paint/{Guid.NewGuid()}");
return Task.CompletedTask;
}

}
2 changes: 0 additions & 2 deletions src/DrawTogether/Components/Pages/Paint.razor
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@

await DoStartupTasks(linkedCts.Token);

await base.OnInitializedAsync();

async Task DoStartupTasks(CancellationToken ct)
{
var localHandleTask = localActor.Ask<IActorRef>(new LocalDrawingSessionActor.GetLocalActorHandle(DrawingSessionId), cancellationToken: ct);
Expand Down

0 comments on commit d899ba9

Please sign in to comment.