Skip to content

Commit

Permalink
admin module initialize the service
Browse files Browse the repository at this point in the history
  • Loading branch information
samihafidiDLW committed Jul 2, 2024
1 parent bd63366 commit 0b4aee0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>$(Company)</Authors>
<Copyright>Copyright © $(Company) $([System.DateTime]::Now.Year)</Copyright>
<Trademark>$(Company)™</Trademark>
<VersionPrefix>1.0.0-beta-1</VersionPrefix>
<VersionPrefix>1.0.1-beta-1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Kentico.Xperience.Typesense.Collection;
using Kentico.Xperience.Typesense.Xperience;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

Expand Down Expand Up @@ -46,5 +47,12 @@ protected override void OnInit(ModuleInitParameters parameters)
ApplicationEvents.PostStart.Execute += InitializeModule;
}

protected override void OnPreInit(ModulePreInitParameters parameters)
{
PreInit(parameters);
var services = parameters.Services;
services.AddKenticoAdminTypesense();
}

private void InitializeModule(object? sender, EventArgs e) => TypesenseCollectionStore.SetIndicies(storageService);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class TypesenseAdminStartupExtensions
/// <param name="configure"></param>
/// <param name="configuration">The application configuration.</param>
/// <returns></returns>
public static IServiceCollection AddKenticoAdminTypesense(this IServiceCollection serviceCollection, Action<ITypesenseBuilder> configure, IConfiguration configuration) =>
public static IServiceCollection AddKenticoAdminTypesense(this IServiceCollection serviceCollection) =>
serviceCollection
.AddSingleton<TypesenseModuleInstaller>()
.AddSingleton<ITypesenseConfigurationKenticoStorageService, DefaultTypesenseConfigurationKenticoStorageService>()
Expand Down
3 changes: 1 addition & 2 deletions examples/DancingGoat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
builder.Services.AddDancingGoatServices();

builder.Services
.AddKenticoTypesenseServices(builder.Configuration)
.AddKenticoAdminTypesenseServices(builder.Configuration); //Only add this line if you are using the Kentico Admin only one app is suppose to do the dequeuing.
.AddKenticoTypesenseServices(builder.Configuration);

ConfigureMembershipServices(builder.Services);

Expand Down
10 changes: 0 additions & 10 deletions examples/DancingGoat/Search/DancingGoatSearchStartupExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,4 @@ public static IServiceCollection AddKenticoTypesenseServices(this IServiceCollec

return services;
}

public static IServiceCollection AddKenticoAdminTypesenseServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddKenticoAdminTypesense(builder =>
{
}, configuration);

return services;
}
}

0 comments on commit 0b4aee0

Please sign in to comment.