add button to copy block item (#1562)

This commit is contained in:
Jason Dove
2024-01-16 10:30:50 -06:00
committed by GitHub
parent ef3b941a39
commit 4805d0d40f
3 changed files with 64 additions and 10 deletions
@@ -17,7 +17,7 @@ public class BlockPlayoutBuilder(
ILogger<BlockPlayoutBuilder> logger)
: IBlockPlayoutBuilder
{
public async Task<Playout> Build(Playout playout, PlayoutBuildMode mode, CancellationToken cancellationToken)
public virtual async Task<Playout> Build(Playout playout, PlayoutBuildMode mode, CancellationToken cancellationToken)
{
Logger.LogDebug(
"Building block playout {PlayoutId} for channel {ChannelNumber} - {ChannelName}",
@@ -19,8 +19,24 @@ public class BlockPlayoutPreviewBuilder(
artistRepository,
logger), IBlockPlayoutPreviewBuilder
{
private readonly Dictionary<Guid, System.Collections.Generic.HashSet<CollectionKey>> _randomizedCollections = [];
protected override ILogger Logger => NullLogger.Instance;
public override async Task<Playout> Build(
Playout playout,
PlayoutBuildMode mode,
CancellationToken cancellationToken)
{
_randomizedCollections.Add(playout.Channel.UniqueId, []);
Playout result = await base.Build(playout, mode, cancellationToken);
_randomizedCollections.Remove(playout.Channel.UniqueId);
return result;
}
protected override Task<int> GetDaysToBuild() => Task.FromResult(1);
protected override IMediaCollectionEnumerator GetEnumerator(
@@ -30,16 +46,25 @@ public class BlockPlayoutPreviewBuilder(
string historyKey,
Map<CollectionKey, List<MediaItem>> collectionMediaItems)
{
IMediaCollectionEnumerator enumerator = base.GetEnumerator(playout, blockItem, currentTime, historyKey, collectionMediaItems);
IMediaCollectionEnumerator enumerator = base.GetEnumerator(
playout,
blockItem,
currentTime,
historyKey,
collectionMediaItems);
var collectionKey = CollectionKey.ForBlockItem(blockItem);
enumerator.ResetState(
new CollectionEnumeratorState
{
Seed = new Random().Next(),
Index = new Random().Next(collectionMediaItems[collectionKey].Count)
});
if (!_randomizedCollections[playout.Channel.UniqueId].Contains(collectionKey))
{
enumerator.ResetState(
new CollectionEnumeratorState
{
Seed = new Random().Next(),
Index = new Random().Next(collectionMediaItems[collectionKey].Count)
});
_randomizedCollections[playout.Channel.UniqueId].Add(collectionKey);
}
return enumerator;
}