diff --git a/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs b/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs index 9481eb9..c2a16d0 100644 --- a/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs +++ b/src/Kentico.Xperience.Algolia/Admin/AlgoliaAdminModule.cs @@ -16,7 +16,7 @@ namespace Kentico.Xperience.Algolia.Admin; internal class AlgoliaAdminModule : AdminModule { private IAlgoliaConfigurationStorageService storageService = null!; - private IServiceProvider serviceProvider = null!; + private AlgoliaModuleInstaller installer = null!; public AlgoliaAdminModule() : base(nameof(AlgoliaAdminModule)) { } @@ -25,15 +25,16 @@ protected override void OnInit(ModuleInitParameters parameters) base.OnInit(parameters); RegisterClientModule("kentico", "xperience-integrations-algolia"); - serviceProvider = parameters.Services; - storageService = serviceProvider.GetRequiredService(); + var services = parameters.Services; + + installer = services.GetRequiredService(); + storageService = services.GetRequiredService(); ApplicationEvents.PostStart.Execute += InitializeModule; } private void InitializeModule(object? sender, EventArgs e) { - var installer = serviceProvider.GetRequiredService(); installer.Install(); AlgoliaIndexStore.SetIndicies(storageService); diff --git a/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs b/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs index 042380e..15c9ea9 100644 --- a/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs +++ b/src/Kentico.Xperience.Algolia/AlgoliaSearchModule.cs @@ -35,9 +35,12 @@ protected override void OnInit(ModuleInitParameters parameters) { base.OnInit(); - algoliaTaskLogger = Service.Resolve(); - appSettingsService = Service.Resolve(); - conversionService = Service.Resolve(); + var services = parameters.Services; + + algoliaTaskLogger = services.GetRequiredService(); + appSettingsService = services.GetRequiredService(); + conversionService = services.GetRequiredService(); + WebPageEvents.Publish.Execute += HandleEvent; WebPageEvents.Delete.Execute += HandleEvent;