Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary null check #17053

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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