refactor(dir): ♻ FilterList.CreateWithApproval()

This commit is contained in:
Collin M. Barrett 2021-11-22 17:21:25 -06:00
parent 1bed7cd864
commit 5cdd64ef41
3 changed files with 6 additions and 5 deletions

View file

@ -56,7 +56,7 @@ public async Task<Response> Handle(Command request, CancellationToken cancellati
.WhereIsDefaultForFilterList()
.SingleAsync(cancellationToken);
var filterList = FilterList.Create(
var filterList = FilterList.CreatePendingApproval(
request.Name,
request.Description,
license,

View file

@ -6,6 +6,5 @@ public interface IRequireChangeApproval<out TChange> where TChange : Change
public IReadOnlyCollection<TChange> PendingChanges => (IReadOnlyCollection<TChange>)Changes.Where(c => c.ApprovedAt == null && c.RejectedAt == null);
public IReadOnlyCollection<TChange> ApprovedChanges => (IReadOnlyCollection<TChange>)Changes.Where(c => c.ApprovedAt != null);
public IReadOnlyCollection<TChange> RejectedChanges => (IReadOnlyCollection<TChange>)Changes.Where(c => c.RejectedAt != null);
public bool IsLegacyApproved => Changes.Count == 0;
public bool IsApproved => IsLegacyApproved || ApprovedChanges.Count > 0;
public bool IsApproved { get; }
}

View file

@ -23,8 +23,9 @@ protected FilterList() { }
public string? EmailAddress { get; private init; }
public Uri? DonateUrl { get; private init; }
public virtual IReadOnlyCollection<FilterListChange> Changes => (IReadOnlyCollection<FilterListChange>)_changes;
public bool IsApproved { get; private init; }
public static FilterList Create(
public static FilterList CreatePendingApproval(
string name,
string? description,
License license,
@ -61,7 +62,8 @@ public static FilterList Create(
ChatUrl = chatUrl,
EmailAddress = emailAddress,
DonateUrl = donateUrl,
ViewUrls = urls
ViewUrls = urls,
IsApproved = false
};
list._changes = new HashSet<FilterListChange>(new[] { FilterListChange.Create(list, createReason) });
return list;