Files
ersatztv/ErsatzTV/Pages/JellyfinPathReplacementsEditor.razor
T
Jason DoveandGitHub 9462156148 fix mysql playout builds (#2352)
* more cancellation tokens and fixes

* so much cancellation token

* fix mysql playout builds
2025-08-27 18:09:56 +00:00

38 lines
1.7 KiB
Plaintext

@page "/media/sources/jellyfin/{Id:int}/paths"
@using ErsatzTV.Application.Jellyfin
@using ErsatzTV.Application.MediaSources
@inject IMediator Mediator
<RemoteMediaSourcePathReplacementsEditor
Id="@Id"
Name="Jellyfin"
GetMediaSourceById="GetMediaSourceById"
GetUpdatePathReplacementsRequest="GetUpdatePathReplacementsRequest"
GetPathReplacementsBySourceId="GetPathReplacementsBySourceId"/>
@code {
[Parameter]
public int Id { get; set; }
private async Task<Option<RemoteMediaSourceViewModel>> GetMediaSourceById(int id, CancellationToken cancellationToken) =>
await Mediator.Send(new GetJellyfinMediaSourceById(Id), cancellationToken)
.MapT(vm => new RemoteMediaSourceViewModel(vm.Id, vm.Name, vm.Address));
private async Task<List<RemoteMediaSourcePathReplacementEditViewModel>> GetPathReplacementsBySourceId(int mediaSourceId, CancellationToken cancellationToken) =>
await Mediator.Send(new GetJellyfinPathReplacementsBySourceId(Id), cancellationToken)
.Map(list => list.Map(ProjectToEditViewModel).ToList());
private RemoteMediaSourcePathReplacementEditViewModel ProjectToEditViewModel(JellyfinPathReplacementViewModel item) =>
new() { Id = item.Id, RemotePath = item.JellyfinPath, LocalPath = item.LocalPath };
private IRequest<Either<BaseError, Unit>> GetUpdatePathReplacementsRequest(List<RemoteMediaSourcePathReplacementEditViewModel> pathReplacements)
{
var items = pathReplacements
.Map(item => new JellyfinPathReplacementItem(item.Id, item.RemotePath, item.LocalPath))
.ToList();
return new UpdateJellyfinPathReplacements(Id, items);
}
}