Skip to content

Commit

Permalink
- fix when target object in block/image merge is already null.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Apr 22, 2024
1 parent 1fb533d commit 94ad0a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions uSync.Core/Roots/Configs/BlockGridConfigMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public virtual object GetMergedConfig(string root, string target)
x => x.Name,
x => x.Name?.StartsWith(_removedLabel) == true);

if (targetConfig.BlockGroups.Length == 0 && targetConfig.Blocks.Length == 0)
return null;

return targetConfig;
}

Expand Down
4 changes: 2 additions & 2 deletions uSync.Core/Roots/Configs/SyncConfigMergerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected TConfig TryGetConfiguration<TConfig>(string value)

protected static TObject[] MergeObjects<TObject, TKey>(TObject[] rootObject, TObject[] targetObject, Func<TObject, TKey> keySelector, Predicate<TObject> predicate)
{
var targetObjectKeys = targetObject.Select(keySelector);
var targetObjectKeys = targetObject?.Select(keySelector) ?? [];

if (targetObjectKeys is IEnumerable<string> targetStrings)
{
Expand All @@ -37,7 +37,7 @@ protected static TObject[] MergeObjects<TObject, TKey>(TObject[] rootObject, TOb
var validRootObjects = rootObject?.Where(x => !targetObjectKeys.Contains(keySelector(x))).ToList()
?? [];

var mergedObject = targetObject.ToList();
var mergedObject = targetObject?.ToList() ?? [];

if (validRootObjects.Count > 0)
{
Expand Down

0 comments on commit 94ad0a6

Please sign in to comment.