* re-namespace * optimize usings * more usings * more of the same * more implicit/global usings * cleanup all usings * minor fixes
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
@page "/media/sources/jellyfin/edit"
|
|
@using ErsatzTV.Core.Jellyfin
|
|
@using ErsatzTV.Application.Jellyfin
|
|
@implements IDisposable
|
|
@inject IMediator _mediator
|
|
@inject NavigationManager _navigationManager
|
|
@inject ISnackbar _snackbar
|
|
@inject ILogger<JellyfinMediaSourceEditor> _logger
|
|
|
|
<RemoteMediaSourceEditor
|
|
Name="Jellyfin"
|
|
LoadSecrets="LoadSecrets"
|
|
SaveSecrets="SaveSecrets"/>
|
|
|
|
@code {
|
|
private readonly CancellationTokenSource _cts = new();
|
|
|
|
public void Dispose()
|
|
{
|
|
_cts.Cancel();
|
|
_cts.Dispose();
|
|
}
|
|
|
|
private async Task<Unit> LoadSecrets(RemoteMediaSourceEditViewModel viewModel)
|
|
{
|
|
JellyfinSecrets secrets = await _mediator.Send(new GetJellyfinSecrets(), _cts.Token);
|
|
viewModel.Address = secrets.Address;
|
|
viewModel.ApiKey = secrets.ApiKey;
|
|
return Unit.Default;
|
|
}
|
|
|
|
private async Task<Either<BaseError, Unit>> SaveSecrets(RemoteMediaSourceEditViewModel viewModel)
|
|
{
|
|
var secrets = new JellyfinSecrets { Address = viewModel.Address, ApiKey = viewModel.ApiKey };
|
|
return await _mediator.Send(new SaveJellyfinSecrets(secrets), _cts.Token);
|
|
}
|
|
|
|
} |