From 9e9b519c253e0889747d6ced5fc33bec92f1545a Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Tue, 16 Mar 2021 11:34:58 -0400 Subject: [PATCH] Fix toasts (#13) --- src/JobsJobsJobs/Client/Shared/MainLayout.razor | 16 +++++++++++++--- src/JobsJobsJobs/Server/Pages/_Host.cshtml | 15 ++++++++------- src/JobsJobsJobs/Server/Startup.cs | 2 ++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/JobsJobsJobs/Client/Shared/MainLayout.razor b/src/JobsJobsJobs/Client/Shared/MainLayout.razor index cda62c6..90e0b7a 100644 --- a/src/JobsJobsJobs/Client/Shared/MainLayout.razor +++ b/src/JobsJobsJobs/Client/Shared/MainLayout.razor @@ -25,9 +25,19 @@ - +@if (InitToasts) +{ + +} @code { - async void PlayJobs() => await js.InvokeVoidAsync("Audio.play", "pelosijobs"); + bool InitToasts = false; + async void PlayJobs() => await js.InvokeVoidAsync("Audio.play", "pelosijobs"); + + protected override void OnAfterRender(bool firstRender) + { + base.OnAfterRender(firstRender); + if (!InitToasts) InitToasts = true; + } } diff --git a/src/JobsJobsJobs/Server/Pages/_Host.cshtml b/src/JobsJobsJobs/Server/Pages/_Host.cshtml index d77f79c..fc855f5 100644 --- a/src/JobsJobsJobs/Server/Pages/_Host.cshtml +++ b/src/JobsJobsJobs/Server/Pages/_Host.cshtml @@ -6,13 +6,14 @@ - - - Jobs, Jobs, Jobs - - - - + + + Jobs, Jobs, Jobs + + + + + diff --git a/src/JobsJobsJobs/Server/Startup.cs b/src/JobsJobsJobs/Server/Startup.cs index ed06bab..25421d2 100644 --- a/src/JobsJobsJobs/Server/Startup.cs +++ b/src/JobsJobsJobs/Server/Startup.cs @@ -1,3 +1,4 @@ +using Blazored.Toast; using JobsJobsJobs.Server.Data; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; @@ -43,6 +44,7 @@ namespace JobsJobsJobs.Server services.AddRazorPages() .AddJsonOptions(options => options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)); + services.AddBlazoredToast(); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;