update xmltv channel list on channel edit (#1570)
This commit is contained in:
@@ -39,6 +39,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Fix crop scale behavior with NVIDIA, QSV acceleration
|
- Fix crop scale behavior with NVIDIA, QSV acceleration
|
||||||
- Fix bug that corrupted uploaded images (watermarks, channel logos)
|
- Fix bug that corrupted uploaded images (watermarks, channel logos)
|
||||||
- Re-uploading images should fix them
|
- Re-uploading images should fix them
|
||||||
|
- Recreate XMLTV channel list (including logos) when channels are edited in ErsatzTV
|
||||||
|
- This bug caused the ErsatzTV logo to be used instead of channel logos in some cases
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Upgrade from .NET 7 to .NET 8
|
- Upgrade from .NET 7 to .NET 8
|
||||||
|
|||||||
@@ -1,33 +1,35 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Channels;
|
||||||
using ErsatzTV.Core;
|
using ErsatzTV.Core;
|
||||||
using ErsatzTV.Core.Domain;
|
using ErsatzTV.Core.Domain;
|
||||||
using ErsatzTV.Core.Domain.Filler;
|
using ErsatzTV.Core.Domain.Filler;
|
||||||
using ErsatzTV.Infrastructure.Data;
|
using ErsatzTV.Infrastructure.Data;
|
||||||
using ErsatzTV.Infrastructure.Extensions;
|
using ErsatzTV.Infrastructure.Extensions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Channel = ErsatzTV.Core.Domain.Channel;
|
||||||
|
|
||||||
namespace ErsatzTV.Application.Channels;
|
namespace ErsatzTV.Application.Channels;
|
||||||
|
|
||||||
public class CreateChannelHandler : IRequestHandler<CreateChannel, Either<BaseError, CreateChannelResult>>
|
public class CreateChannelHandler(
|
||||||
|
ChannelWriter<IBackgroundServiceRequest> workerChannel,
|
||||||
|
IDbContextFactory<TvContext> dbContextFactory)
|
||||||
|
: IRequestHandler<CreateChannel, Either<BaseError, CreateChannelResult>>
|
||||||
{
|
{
|
||||||
private readonly IDbContextFactory<TvContext> _dbContextFactory;
|
|
||||||
|
|
||||||
public CreateChannelHandler(IDbContextFactory<TvContext> dbContextFactory) => _dbContextFactory = dbContextFactory;
|
|
||||||
|
|
||||||
public async Task<Either<BaseError, CreateChannelResult>> Handle(
|
public async Task<Either<BaseError, CreateChannelResult>> Handle(
|
||||||
CreateChannel request,
|
CreateChannel request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
|
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
|
||||||
return await validation.Apply(c => PersistChannel(dbContext, c));
|
return await validation.Apply(c => PersistChannel(dbContext, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<CreateChannelResult> PersistChannel(TvContext dbContext, Channel channel)
|
private async Task<CreateChannelResult> PersistChannel(TvContext dbContext, Channel channel)
|
||||||
{
|
{
|
||||||
await dbContext.Channels.AddAsync(channel);
|
await dbContext.Channels.AddAsync(channel);
|
||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
|
await workerChannel.WriteAsync(new RefreshChannelList());
|
||||||
return new CreateChannelResult(channel.Id);
|
return new CreateChannelResult(channel.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,26 +12,18 @@ using Channel = ErsatzTV.Core.Domain.Channel;
|
|||||||
|
|
||||||
namespace ErsatzTV.Application.Channels;
|
namespace ErsatzTV.Application.Channels;
|
||||||
|
|
||||||
public class UpdateChannelHandler : IRequestHandler<UpdateChannel, Either<BaseError, ChannelViewModel>>
|
public class UpdateChannelHandler(
|
||||||
|
ChannelWriter<IBackgroundServiceRequest> workerChannel,
|
||||||
|
IDbContextFactory<TvContext> dbContextFactory)
|
||||||
|
: IRequestHandler<UpdateChannel, Either<BaseError, ChannelViewModel>>
|
||||||
{
|
{
|
||||||
private readonly IDbContextFactory<TvContext> _dbContextFactory;
|
|
||||||
private readonly ChannelWriter<IBackgroundServiceRequest> _workerChannel;
|
|
||||||
|
|
||||||
public UpdateChannelHandler(
|
|
||||||
ChannelWriter<IBackgroundServiceRequest> workerChannel,
|
|
||||||
IDbContextFactory<TvContext> dbContextFactory)
|
|
||||||
{
|
|
||||||
_workerChannel = workerChannel;
|
|
||||||
_dbContextFactory = dbContextFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Either<BaseError, ChannelViewModel>> Handle(
|
public async Task<Either<BaseError, ChannelViewModel>> Handle(
|
||||||
UpdateChannel request,
|
UpdateChannel request,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
|
Validation<BaseError, Channel> validation = await Validate(dbContext, request);
|
||||||
return await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request));
|
return await validation.Apply(c => ApplyUpdateRequest(dbContext, c, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<ChannelViewModel> ApplyUpdateRequest(TvContext dbContext, Channel c, UpdateChannel update)
|
private async Task<ChannelViewModel> ApplyUpdateRequest(TvContext dbContext, Channel c, UpdateChannel update)
|
||||||
@@ -85,9 +77,11 @@ public class UpdateChannelHandler : IRequestHandler<UpdateChannel, Either<BaseEr
|
|||||||
|
|
||||||
foreach (Playout playout in maybePlayout)
|
foreach (Playout playout in maybePlayout)
|
||||||
{
|
{
|
||||||
await _workerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
|
await workerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await workerChannel.WriteAsync(new RefreshChannelList());
|
||||||
|
|
||||||
return ProjectToViewModel(c);
|
return ProjectToViewModel(c);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user