Skip to content

Commit

Permalink
Merge pull request #612 from neozhu/PermissionSet
Browse files Browse the repository at this point in the history
🐛 fix INotificationService Preload
  • Loading branch information
neozhu authored Feb 15, 2024
2 parents bc42888 + c641dcf commit 60db6d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 7 additions & 6 deletions src/Server.UI/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ public static IServiceCollection AddServerUI(this IServiceCollection services, I
.AddBlazorDownloadFile()
.AddScoped<IUserPreferencesService, UserPreferencesService>()
.AddScoped<IMenuService, MenuService>()
.AddScoped<INotificationService, InMemoryNotificationService>();
.AddScoped<InMemoryNotificationService>()
.AddScoped<INotificationService>(sp =>
{
var service = sp.GetRequiredService<InMemoryNotificationService>();
service.Preload();
return service;
});

return services;
}
Expand Down Expand Up @@ -96,21 +102,16 @@ public static WebApplication ConfigureServer(this WebApplication app, IConfigura
.SetDefaultCulture(LocalizationConstants.SupportedLanguages.Select(x => x.Code).First())
.AddSupportedCultures(LocalizationConstants.SupportedLanguages.Select(x => x.Code).ToArray())
.AddSupportedUICultures(LocalizationConstants.SupportedLanguages.Select(x => x.Code).ToArray());

app.UseRequestLocalization(localizationOptions);

app.UseMiddleware<LocalizationCookiesMiddleware>();
app.UseExceptionHandler();
app.UseHangfireDashboard("/jobs", new DashboardOptions
{
Authorization = new[] { new HangfireDashboardAuthorizationFilter() },
AsyncAuthorization = new[] { new HangfireDashboardAsyncAuthorizationFilter() }
});


app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
app.MapHub<ServerHub>(ISignalRHub.Url);

return app;
}
}
6 changes: 2 additions & 4 deletions src/Server.UI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CleanArchitecture.Blazor.Application;
using CleanArchitecture.Blazor.Application;
using CleanArchitecture.Blazor.Infrastructure;
using CleanArchitecture.Blazor.Infrastructure.Persistence;
using CleanArchitecture.Blazor.Server;
Expand Down Expand Up @@ -27,9 +27,7 @@
var initializer = scope.ServiceProvider.GetRequiredService<ApplicationDbContextInitializer>();
await initializer.InitialiseAsync();
await initializer.SeedAsync();
var notificationService = scope.ServiceProvider.GetService<INotificationService>();
if (notificationService is InMemoryNotificationService inMemoryNotificationService)
inMemoryNotificationService.Preload();

}

await app.RunAsync();

0 comments on commit 60db6d4

Please sign in to comment.