Files
ersatztv/ErsatzTV/Pages/EmbyPathReplacementsEditor.razor
T
Jason DoveandGitHub 5d081ceeff fix editorconfig and run code cleanup (#2324)
* fix formatting rules

* reformat ersatztv

* reformat ersatztv.application

* reformat ersatztv.core

* refactor ersatztv.core.tests

* reformat ersatztv.ffmpeg

* reformat ersatztv.ffmpeg.tests

* reformat ersatztv.infrastructure

* cleanup infra mysql

* cleanup infra sqlite

* cleanup infra tests

* cleanup ersatztv.scanner

* cleanup ersatztv.scanner.tests

* sln cleanup

* update dependencies
2025-08-16 14:44:48 +00:00

47 lines
1.7 KiB
Plaintext

@page "/media/sources/emby/{Id:int}/paths"
@using ErsatzTV.Application.Emby
@using ErsatzTV.Application.MediaSources
@implements IDisposable
@inject IMediator Mediator
<RemoteMediaSourcePathReplacementsEditor
Id="@Id"
Name="Emby"
GetMediaSourceById="GetMediaSourceById"
GetUpdatePathReplacementsRequest="GetUpdatePathReplacementsRequest"
GetPathReplacementsBySourceId="GetPathReplacementsBySourceId"/>
@code {
private readonly CancellationTokenSource _cts = new();
[Parameter]
public int Id { get; set; }
public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
}
private Task<Option<RemoteMediaSourceViewModel>> GetMediaSourceById(int id) =>
Mediator.Send(new GetEmbyMediaSourceById(Id), _cts.Token)
.MapT(vm => new RemoteMediaSourceViewModel(vm.Id, vm.Name, vm.Address));
private Task<List<RemoteMediaSourcePathReplacementEditViewModel>> GetPathReplacementsBySourceId(int mediaSourceId) =>
Mediator.Send(new GetEmbyPathReplacementsBySourceId(Id), _cts.Token)
.Map(list => list.Map(ProjectToEditViewModel).ToList());
private RemoteMediaSourcePathReplacementEditViewModel ProjectToEditViewModel(EmbyPathReplacementViewModel item) =>
new() { Id = item.Id, RemotePath = item.EmbyPath, LocalPath = item.LocalPath };
private IRequest<Either<BaseError, Unit>> GetUpdatePathReplacementsRequest(List<RemoteMediaSourcePathReplacementEditViewModel> pathReplacements)
{
var items = pathReplacements
.Map(item => new EmbyPathReplacementItem(item.Id, item.RemotePath, item.LocalPath))
.ToList();
return new UpdateEmbyPathReplacements(Id, items);
}
}