Skip to content

Commit 274bc9b

Browse files
committed
Merge branch 'maintenance/ViewModels-defaults' into develop
Previously, some view model defaults were set on both the property's auto-value, as well as the `AttributeDictionary` constructor. This ensures that the constructor instead falls back to the auto-value. While this isn't strictly required, it helps avoid scenarios where the default value is updated in one place, but accidentally overlooked in the other.
2 parents 68d330e + b605ad4 commit 274bc9b

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

OnTopic.ViewModels/TopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public record TopicViewModel: ITopicViewModel, ICoreTopicViewModel, IAssociatedT
2929
/// <param name="attributes">An <see cref="AttributeDictionary"/> of attribute values.</param>
3030
public TopicViewModel(AttributeDictionary attributes) {
3131
Contract.Requires(attributes, nameof(attributes));
32-
IsHidden = attributes.GetBoolean("IsHidden")?? false;
32+
IsHidden = attributes.GetBoolean("IsHidden")?? IsHidden;
3333
View = attributes.GetValue("View");
3434
}
3535

OnTopic.ViewModels/_contentTypes/ContentListTopicViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public record ContentListTopicViewModel: PageTopicViewModel {
2828
/// <param name="attributes">An <see cref="AttributeDictionary"/> of attribute values.</param>
2929
public ContentListTopicViewModel(AttributeDictionary attributes): base(attributes) {
3030
Contract.Requires(attributes, nameof(attributes));
31-
IsIndexed = attributes.GetBoolean(nameof(IsIndexed))?? false;
32-
IndexLabel = attributes.GetValue(nameof(IndexLabel))?? "Contents";
31+
IsIndexed = attributes.GetBoolean(nameof(IsIndexed))?? IsIndexed;
32+
IndexLabel = attributes.GetValue(nameof(IndexLabel))?? IndexLabel;
3333
}
3434

3535
/// <summary>

OnTopic.ViewModels/_contentTypes/PageTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public PageTopicViewModel(AttributeDictionary attributes): base(attributes) {
3333
MetaTitle = attributes.GetValue(nameof(MetaTitle));
3434
MetaDescription = attributes.GetValue(nameof(MetaDescription));
3535
MetaKeywords = attributes.GetValue(nameof(MetaKeywords));
36-
NoIndex = attributes.GetBoolean(nameof(NoIndex))?? false;
36+
NoIndex = attributes.GetBoolean(nameof(NoIndex))?? NoIndex;
3737
Body = attributes.GetValue(nameof(Body));
3838
}
3939

0 commit comments

Comments
 (0)