From 57ca869652a27ee141d6fcaab7fa2c27c451b545 Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Sat, 20 Feb 2021 11:40:36 -0600 Subject: [PATCH] don't get stuck building a playout with an empty collection --- ErsatzTV.Core/Scheduling/PlayoutBuilder.cs | 11 +++++++++++ ErsatzTV/Shared/RemoveFromCollectionDialog.razor | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs b/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs index acf835b82..e6b3f3945 100644 --- a/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs +++ b/ErsatzTV.Core/Scheduling/PlayoutBuilder.cs @@ -7,6 +7,7 @@ using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; using ErsatzTV.Core.Interfaces.Scheduling; using LanguageExt; +using LanguageExt.UnsafeValueAccess; using Microsoft.Extensions.Logging; using static LanguageExt.Prelude; using Map = LanguageExt.Map; @@ -57,6 +58,16 @@ namespace ErsatzTV.Core.Scheduling playout.Channel.Number, playout.Channel.Name); + Option emptyCollection = collectionMediaItems.Find(c => !c.Value.Any()).Map(c => c.Key.Name); + if (emptyCollection.IsSome) + { + _logger.LogError( + "Unable to rebuild playout; collection {Name} has no items!", + emptyCollection.ValueUnsafe()); + + return playout; + } + playout.Items ??= new List(); playout.ProgramScheduleAnchors ??= new List(); diff --git a/ErsatzTV/Shared/RemoveFromCollectionDialog.razor b/ErsatzTV/Shared/RemoveFromCollectionDialog.razor index 229bcf22c..da643724b 100644 --- a/ErsatzTV/Shared/RemoveFromCollectionDialog.razor +++ b/ErsatzTV/Shared/RemoveFromCollectionDialog.razor @@ -34,7 +34,7 @@ [Parameter] public string DetailHighlight { get; set; } - private string FormatText() => $"Are you sure you want to remove the {EntityType} {EntityName} from this collection?"; + private string FormatText() => $"Do you really want to remove the {EntityType} {EntityName} from this collection?"; private void Submit() => MudDialog.Close(DialogResult.Ok(true));