Skip to content

Commit 020d5a5

Browse files
committed
Toggle PropertyIndexValueFactory between deprecated methods; Minor UI fix.
1 parent 49176ae commit 020d5a5

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/Umbraco.Cms.Integrations.Search.Algolia/App_Plugins/UmbracoCms.Integrations/Search/Algolia/js/dashboard.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@
382382
headline: 'Algolia',
383383
message: 'Index built successfully'
384384
});
385-
vm.loading = false;
386385
}
387386
});
387+
vm.loading = false;
388388

389389
closeBuildDialog();
390390
}

src/Umbraco.Cms.Integrations.Search.Algolia/Services/AlgoliaSearchPropertyIndexValueFactory.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
using Umbraco.Cms.Core.Models;
2-
using Umbraco.Cms.Core.Models.PublishedContent;
32
using Umbraco.Cms.Core.PropertyEditors;
3+
using Umbraco.Cms.Core.Services;
44
using Umbraco.Cms.Integrations.Search.Algolia.Providers;
55

66
namespace Umbraco.Cms.Integrations.Search.Algolia.Services
77
{
88
public class AlgoliaSearchPropertyIndexValueFactory : IAlgoliaSearchPropertyIndexValueFactory
99
{
1010
private readonly PropertyEditorCollection _propertyEditorsCollection;
11-
1211
private readonly ConverterCollection _converterCollection;
1312

13+
private readonly ILocalizationService _localizationService;
14+
private readonly IContentTypeService _contentTypeService;
15+
1416
public AlgoliaSearchPropertyIndexValueFactory(
1517
PropertyEditorCollection propertyEditorCollection,
16-
ConverterCollection converterCollection)
18+
ConverterCollection converterCollection,
19+
ILocalizationService localizationService,
20+
IContentTypeService contentTypeService)
1721
{
1822
_propertyEditorsCollection = propertyEditorCollection;
19-
2023
_converterCollection = converterCollection;
24+
_localizationService = localizationService;
25+
_contentTypeService = contentTypeService;
2126
}
2227

2328
public virtual KeyValuePair<string, object> GetValue(IProperty property, string culture)
2429
{
30+
var availableCultures = _localizationService.GetAllLanguages().Select(p => p.IsoCode);
31+
IDictionary<Guid, IContentType> contentTypeDictionary = _contentTypeService.GetAll().ToDictionary(x => x.Key);
32+
2533
var propertyEditor = _propertyEditorsCollection.FirstOrDefault(p => p.Alias == property.PropertyType.PropertyEditorAlias);
2634
if (propertyEditor == null)
2735
{
@@ -35,8 +43,22 @@ public virtual KeyValuePair<string, object> GetValue(IProperty property, string
3543
return new KeyValuePair<string, object>(property.Alias, result);
3644
}
3745

38-
IEnumerable<KeyValuePair<string, IEnumerable<object>>> indexValues = propertyEditor.PropertyIndexValueFactory.GetIndexValues(property, culture, null, true);
39-
46+
IEnumerable<KeyValuePair<string, IEnumerable<object>>> indexValues =
47+
#if NET6_0 || NET7_0
48+
propertyEditor.PropertyIndexValueFactory.GetIndexValues(
49+
property,
50+
culture,
51+
null,
52+
true);
53+
#else
54+
propertyEditor.PropertyIndexValueFactory.GetIndexValues(
55+
property,
56+
culture,
57+
null,
58+
true,
59+
availableCultures,
60+
contentTypeDictionary);
61+
#endif
4062
if (indexValues == null || !indexValues.Any()) return new KeyValuePair<string, object>(property.Alias, string.Empty);
4163

4264
var indexValue = indexValues.First();

0 commit comments

Comments
 (0)