use cancellation tokens in ui (#666)

* use cancellation tokens in pages

* use cancellation token in shared ui

* use cancellation tokens in artwork controller
This commit is contained in:
Jason Dove
2022-03-01 21:31:48 -06:00
committed by GitHub
parent 9e2f445785
commit 452f361384
66 changed files with 762 additions and 306 deletions
@@ -4,6 +4,8 @@
@using ErsatzTV.Application.Jellyfin
@using ErsatzTV.Application.Jellyfin.Commands
@using Unit = LanguageExt.Unit
@using System.Threading
@implements IDisposable
@inject NavigationManager _navigationManager
@inject ILogger<ScheduleItemsEditor> _logger
@inject ISnackbar _snackbar
@@ -17,16 +19,23 @@
GetPathReplacementsBySourceId="GetPathReplacementsBySourceId"/>
@code {
private readonly CancellationTokenSource _cts = new();
[Parameter]
public int Id { get; set; }
private Task<Option<RemoteMediaSourceViewModel>> GetMediaSourceById(int id) =>
_mediator.Send(new GetJellyfinMediaSourceById(Id))
public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
}
private async Task<Option<RemoteMediaSourceViewModel>> GetMediaSourceById(int id) =>
await _mediator.Send(new GetJellyfinMediaSourceById(Id), _cts.Token)
.MapT(vm => new RemoteMediaSourceViewModel(vm.Id, vm.Name, vm.Address));
private Task<List<RemoteMediaSourcePathReplacementEditViewModel>> GetPathReplacementsBySourceId(int mediaSourceId) =>
_mediator.Send(new GetJellyfinPathReplacementsBySourceId(Id))
private async Task<List<RemoteMediaSourcePathReplacementEditViewModel>> GetPathReplacementsBySourceId(int mediaSourceId) =>
await _mediator.Send(new GetJellyfinPathReplacementsBySourceId(Id), _cts.Token)
.Map(list => list.Map(ProjectToEditViewModel).ToList());
private RemoteMediaSourcePathReplacementEditViewModel ProjectToEditViewModel(JellyfinPathReplacementViewModel item) =>