* use cancellation tokens in pages * use cancellation token in shared ui * use cancellation tokens in artwork controller
32 lines
1.1 KiB
Plaintext
32 lines
1.1 KiB
Plaintext
@page "/media/sources/jellyfin"
|
|
@using ErsatzTV.Core.Interfaces.Jellyfin
|
|
@using ErsatzTV.Application.Jellyfin.Commands
|
|
@using ErsatzTV.Application.Jellyfin.Queries
|
|
@using System.Threading
|
|
@implements IDisposable
|
|
@inject IJellyfinSecretStore _jellyfinSecretStore
|
|
@inject ChannelWriter<IJellyfinBackgroundServiceRequest> _channel
|
|
|
|
<RemoteMediaSources
|
|
TViewModel="ErsatzTV.Application.Jellyfin.JellyfinMediaSourceViewModel"
|
|
TSecrets="ErsatzTV.Core.Jellyfin.JellyfinSecrets"
|
|
TMediaSource="JellyfinMediaSource"
|
|
Name="Jellyfin"
|
|
GetAllMediaSourcesCommand="@(new GetAllJellyfinMediaSources())"
|
|
DisconnectCommand="@(new DisconnectJellyfin())"
|
|
RefreshLibrariesCommand="@(mediaSourceId => RefreshLibraries(mediaSourceId))"
|
|
SecretStore="@_jellyfinSecretStore"/>
|
|
|
|
@code {
|
|
private readonly CancellationTokenSource _cts = new();
|
|
|
|
public void Dispose()
|
|
{
|
|
_cts.Cancel();
|
|
_cts.Dispose();
|
|
}
|
|
|
|
private async Task RefreshLibraries(int mediaSourceId) =>
|
|
await _channel.WriteAsync(new SynchronizeJellyfinLibraries(mediaSourceId), _cts.Token);
|
|
|
|
} |