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:
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user