Browse Source

hide unused local libraries (#655)

pull/656/head
Jason Dove 3 years ago committed by GitHub
parent
commit
b25f783343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 2
      ErsatzTV.Application/Libraries/Queries/GetConfiguredLibraries.cs
  3. 11
      ErsatzTV.Application/Libraries/Queries/GetConfiguredLibrariesHandler.cs
  4. 1
      ErsatzTV.Infrastructure/Data/Repositories/LibraryRepository.cs
  5. 2
      ErsatzTV/Pages/Libraries.razor

1
CHANGELOG.md

@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Disable framerate normalization by default and on all ffmpeg profiles
- If framerate normalization is desired (not typically needed), it can be re-enabled manually
- Show watermarks over songs
- Hide unused local libraries
## [0.4.1-alpha] - 2022-02-10
### Fixed

2
ErsatzTV.Application/Libraries/Queries/GetAllLibraries.cs → ErsatzTV.Application/Libraries/Queries/GetConfiguredLibraries.cs

@ -3,5 +3,5 @@ using MediatR; @@ -3,5 +3,5 @@ using MediatR;
namespace ErsatzTV.Application.Libraries.Queries
{
public record GetAllLibraries : IRequest<List<LibraryViewModel>>;
public record GetConfiguredLibraries : IRequest<List<LibraryViewModel>>;
}

11
ErsatzTV.Application/Libraries/Queries/GetAllLibrariesHandler.cs → ErsatzTV.Application/Libraries/Queries/GetConfiguredLibrariesHandler.cs

@ -10,13 +10,16 @@ using static ErsatzTV.Application.Libraries.Mapper; @@ -10,13 +10,16 @@ using static ErsatzTV.Application.Libraries.Mapper;
namespace ErsatzTV.Application.Libraries.Queries
{
public class GetAllLibrariesHandler : IRequestHandler<GetAllLibraries, List<LibraryViewModel>>
public class GetConfiguredLibrariesHandler : IRequestHandler<GetConfiguredLibraries, List<LibraryViewModel>>
{
private readonly ILibraryRepository _libraryRepository;
public GetAllLibrariesHandler(ILibraryRepository libraryRepository) => _libraryRepository = libraryRepository;
public GetConfiguredLibrariesHandler(ILibraryRepository libraryRepository) =>
_libraryRepository = libraryRepository;
public Task<List<LibraryViewModel>> Handle(GetAllLibraries request, CancellationToken cancellationToken) =>
public Task<List<LibraryViewModel>> Handle(
GetConfiguredLibraries request,
CancellationToken cancellationToken) =>
_libraryRepository.GetAll()
.Map(
list => list.Filter(ShouldIncludeLibrary)
@ -28,7 +31,7 @@ namespace ErsatzTV.Application.Libraries.Queries @@ -28,7 +31,7 @@ namespace ErsatzTV.Application.Libraries.Queries
private static bool ShouldIncludeLibrary(Library library) =>
library switch
{
LocalLibrary => true,
LocalLibrary => library.Paths.Count > 0,
PlexLibrary plex => plex.ShouldSyncItems,
JellyfinLibrary jellyfin => jellyfin.ShouldSyncItems,
EmbyLibrary emby => emby.ShouldSyncItems,

1
ErsatzTV.Infrastructure/Data/Repositories/LibraryRepository.cs

@ -62,6 +62,7 @@ namespace ErsatzTV.Infrastructure.Data.Repositories @@ -62,6 +62,7 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
return context.Libraries
.AsNoTracking()
.Include(l => l.MediaSource)
.Include(l => l.Paths)
.ToListAsync();
}

2
ErsatzTV/Pages/Libraries.razor

@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
private async Task LoadLibraries()
{
_libraries = await _mediator.Send(new GetAllLibraries());
_libraries = await _mediator.Send(new GetConfiguredLibraries());
_progressByLibrary = _libraries.ToDictionary(vm => vm.Id, _ => 0);
}

Loading…
Cancel
Save