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