Files
ersatztv/ErsatzTV/Pages/PlexPathReplacementsEditor.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.6 KiB
Plaintext

@page "/media/sources/plex/{Id:int}/paths"
@using ErsatzTV.Application.MediaSources
@using ErsatzTV.Application.Plex
@inject IMediator Mediator
<RemoteMediaSourcePathReplacementsEditor
Id="@Id"
Name="Plex"
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 GetPlexMediaSourceById(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 GetPlexPathReplacementsBySourceId(Id), cancellationToken)
.Map(list => list.Map(ProjectToEditViewModel).ToList());
private RemoteMediaSourcePathReplacementEditViewModel ProjectToEditViewModel(PlexPathReplacementViewModel item) =>
new() { Id = item.Id, RemotePath = item.PlexPath, LocalPath = item.LocalPath };
private IRequest<Either<BaseError, Unit>> GetUpdatePathReplacementsRequest(List<RemoteMediaSourcePathReplacementEditViewModel> pathReplacements)
{
var items = pathReplacements
.Map(item => new PlexPathReplacementItem(item.Id, item.RemotePath, item.LocalPath))
.ToList();
return new UpdatePlexPathReplacements(Id, items);
}
}