Skip to content

Commit

Permalink
Remove unnecessary null check (#17053)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco authored Nov 24, 2024
1 parent 3421e74 commit 299a254
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,16 +530,13 @@ public async Task<IActionResult> DiscardDraft(string contentItemId, string retur
return Forbid();
}

if (contentItem != null)
{
await _contentManager.DiscardDraftAsync(contentItem);
await _contentManager.DiscardDraftAsync(contentItem);

var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType);
var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType);

await _notifier.SuccessAsync(string.IsNullOrWhiteSpace(typeDefinition?.DisplayName)
? H["The draft has been removed."]
: H["The {0} draft has been removed.", typeDefinition.DisplayName]);
}
await _notifier.SuccessAsync(string.IsNullOrWhiteSpace(typeDefinition?.DisplayName)
? H["The draft has been removed."]
: H["The {0} draft has been removed.", typeDefinition.DisplayName]);

return Url.IsLocalUrl(returnUrl)
? this.LocalRedirect(returnUrl, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,19 @@ Task<IDisplayResult> IContentFieldDisplayDriver.BuildEditorAsync(ContentPart con

var field = contentPart.GetOrCreate<TField>(partFieldDefinition.Name);

if (field != null)
{
BuildPrefix(typePartDefinition, partFieldDefinition, context.HtmlFieldPrefix);
BuildPrefix(typePartDefinition, partFieldDefinition, context.HtmlFieldPrefix);

var fieldEditorContext = new BuildFieldEditorContext(contentPart, typePartDefinition, partFieldDefinition, context);
var fieldEditorContext = new BuildFieldEditorContext(contentPart, typePartDefinition, partFieldDefinition, context);

_typePartDefinition = typePartDefinition;
_partFieldDefinition = partFieldDefinition;
_typePartDefinition = typePartDefinition;
_partFieldDefinition = partFieldDefinition;

var result = EditAsync(field, fieldEditorContext);
var result = EditAsync(field, fieldEditorContext);

_typePartDefinition = null;
_partFieldDefinition = null;

return result;
}
_typePartDefinition = null;
_partFieldDefinition = null;

return Task.FromResult(default(IDisplayResult));
return result;
}

async Task<IDisplayResult> IContentFieldDisplayDriver.UpdateEditorAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, UpdateEditorContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,14 @@ private async Task ApplyImplementationAsync(BuildShapeContext context, string di
newShapeMetadata.Wrappers.Clear();
}

if (placement != null)
if (placement.Alternates != null)
{
if (placement.Alternates != null)
{
newShapeMetadata.Alternates.AddRange(placement.Alternates);
}
newShapeMetadata.Alternates.AddRange(placement.Alternates);
}

if (placement.Wrappers != null)
{
newShapeMetadata.Wrappers.AddRange(placement.Wrappers);
}
if (placement.Wrappers != null)
{
newShapeMetadata.Wrappers.AddRange(placement.Wrappers);
}

var parentShape = context.Shape;
Expand Down

0 comments on commit 299a254

Please sign in to comment.