@page "/media/sources/local" @using ErsatzTV.Application.Libraries @using ErsatzTV.Application.Libraries.Commands @using ErsatzTV.Application.Libraries.Queries @implements IDisposable @inject IDialogService _dialog @inject IMediator _mediator @inject IEntityLocker _locker @inject ChannelWriter _workerChannel @inject ChannelWriter _plexWorkerChannel @inject ChannelWriter _jellyfinWorkerChannel @inject ChannelWriter _embyWorkerChannel Local Libraries Name Media Kind @context.Name @context.MediaKind
Add Local Library
@code { private IList _libraries; protected override void OnInitialized() { _locker.OnLibraryChanged += LockChanged; } protected override async Task OnParametersSetAsync() => await LoadLibraries(); private async Task LoadLibraries() { _libraries = await _mediator.Send(new GetAllLocalLibraries()); } private void LockChanged(object sender, EventArgs e) => InvokeAsync(StateHasChanged); private async Task DeleteLibrary(LocalLibraryViewModel library) { int count = await _mediator.Send(new CountMediaItemsByLibrary(library.Id)); var parameters = new DialogParameters { { "EntityType", "library" }, { "EntityName", library.Name }, { "DetailText", $"This library contains {count} media items." }, { "DetailHighlight", count.ToString() } }; var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialog = _dialog.Show("Delete Library", parameters, options); DialogResult result = await dialog.Result; if (!result.Cancelled) { await _mediator.Send(new DeleteLocalLibrary(library.Id)); await LoadLibraries(); } } void IDisposable.Dispose() { _locker.OnLibraryChanged -= LockChanged; } }