use Guid for Key

This commit is contained in:
Niels Lyngsø
2020-06-04 11:32:44 +02:00
parent 7077b5111e
commit 4ffc69b7f5
2 changed files with 5 additions and 5 deletions

View File

@@ -161,17 +161,17 @@ namespace Umbraco.Web.PropertyEditors
internal class BlockEditorValues
{
private readonly IBlockEditorDataHelper _dataHelper;
private readonly Lazy<Dictionary<string, IContentType>> _contentTypes;
private readonly Lazy<Dictionary<Guid, IContentType>> _contentTypes;
public BlockEditorValues(IBlockEditorDataHelper dataHelper, IContentTypeService contentTypeService)
{
_dataHelper = dataHelper;
_contentTypes = new Lazy<Dictionary<string, IContentType>>(() => contentTypeService.GetAll().ToDictionary(c => c.Key));
_contentTypes = new Lazy<Dictionary<Guid, IContentType>>(() => contentTypeService.GetAll().ToDictionary(c => c.Key));
}
private IContentType GetElementType(JObject item)
{
var contentTypeKey = item[ContentTypeKeyPropertyKey]?.ToObject<string>() ?? string.Empty;
Guid contentTypeKey = item[ContentTypeKeyPropertyKey]?.ToObject<Guid>() ?? Guid.Empty;
_contentTypes.Value.TryGetValue(contentTypeKey, out var contentType);
return contentType;
}

View File

@@ -102,8 +102,8 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
if (!elements.TryGetValue(guidUdi.Guid, out var data))
continue;
// TODO: make this work with key, not Alias.
if (!contentTypeMap.TryGetValue(data.ContentType.Alias, out var blockConfig))
// Make this work with Key, not alias, since contentTypeMap is now a dctionary with contentTypeKey as the dictionary key.
if (!contentTypeMap.TryGetValue(data.ContentType.Key, out var blockConfig))
continue;
// this can happen if they have a settings type, save content, remove the settings type, and display the front-end page before saving the content again