Browse Source

don't get stuck building a playout with an empty collection

pull/26/head
Jason Dove 6 years ago
parent
commit
57ca869652
  1. 11
      ErsatzTV.Core/Scheduling/PlayoutBuilder.cs
  2. 2
      ErsatzTV/Shared/RemoveFromCollectionDialog.razor

11
ErsatzTV.Core/Scheduling/PlayoutBuilder.cs

@ -7,6 +7,7 @@ using ErsatzTV.Core.Domain; @@ -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 @@ -57,6 +58,16 @@ namespace ErsatzTV.Core.Scheduling
playout.Channel.Number,
playout.Channel.Name);
Option<string> 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<PlayoutItem>();
playout.ProgramScheduleAnchors ??= new List<PlayoutProgramScheduleAnchor>();

2
ErsatzTV/Shared/RemoveFromCollectionDialog.razor

@ -34,7 +34,7 @@ @@ -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));

Loading…
Cancel
Save