aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/UserViewManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Library/UserViewManager.cs55
1 files changed, 32 insertions, 23 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
index 4beb34e4f..46c32cc56 100644
--- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs
@@ -2,9 +2,7 @@
using MediaBrowser.Controller;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
-using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Localization;
@@ -60,48 +58,52 @@ namespace MediaBrowser.Server.Implementations.Library
var standaloneFolders = folders.Where(i => UserView.IsExcludedFromGrouping(i) || excludeFolderIds.Contains(i.Id)).ToList();
- list.AddRange(standaloneFolders);
-
- var recursiveChildren = folders
+ var foldersWithViewTypes = folders
.Except(standaloneFolders)
- .SelectMany(i => i.GetRecursiveChildren(user, false))
+ .OfType<ICollectionFolder>()
.ToList();
- if (recursiveChildren.OfType<Series>().Any())
+ list.AddRange(standaloneFolders);
+
+ if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) ||
+ foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType)))
{
- list.Add(await GetUserView(CollectionType.TvShows, user, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.TvShows, string.Empty, cancellationToken).ConfigureAwait(false));
}
- if (recursiveChildren.OfType<MusicAlbum>().Any() ||
- recursiveChildren.OfType<MusicVideo>().Any())
+ if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) ||
+ foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)))
{
- list.Add(await GetUserView(CollectionType.Music, user, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Music, string.Empty, cancellationToken).ConfigureAwait(false));
}
- if (recursiveChildren.OfType<Movie>().Any())
+ if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) ||
+ foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType)))
{
- list.Add(await GetUserView(CollectionType.Movies, user, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Movies, string.Empty, cancellationToken).ConfigureAwait(false));
}
- if (recursiveChildren.OfType<Game>().Any())
+ if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)))
{
- list.Add(await GetUserView(CollectionType.Games, user, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Games, string.Empty, cancellationToken).ConfigureAwait(false));
}
if (user.Configuration.DisplayCollectionsView &&
- recursiveChildren.OfType<BoxSet>().Any())
+ folders
+ .Except(standaloneFolders)
+ .SelectMany(i => i.GetRecursiveChildren(user, false)).OfType<BoxSet>().Any())
{
- list.Add(await GetUserView(CollectionType.BoxSets, user, string.Empty, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false));
}
- if (recursiveChildren.OfType<Playlist>().Any())
+ if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)))
{
list.Add(_playlists.GetPlaylistsFolder(user.Id.ToString("N")));
}
if (user.Configuration.DisplayFoldersView)
{
- list.Add(await GetUserView(CollectionType.Folders, user, "zz_" + CollectionType.Folders, cancellationToken).ConfigureAwait(false));
+ list.Add(await GetUserView(CollectionType.Folders, "zz_" + CollectionType.Folders, cancellationToken).ConfigureAwait(false));
}
if (query.IncludeExternalContent)
@@ -146,16 +148,23 @@ namespace MediaBrowser.Server.Implementations.Library
.ThenBy(i => i.SortName);
}
- public Task<UserView> GetUserView(string category, string type, User user, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetUserView(string name, string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
+ {
+ return _libraryManager.GetSpecialFolder(user, name, parentId, type, sortName, cancellationToken);
+ }
+
+ public Task<UserView> GetUserView(string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
{
var name = _localizationManager.GetLocalizedString("ViewType" + type);
- return _libraryManager.GetNamedView(name, category, type, sortName, cancellationToken);
+ return GetUserView(name, parentId, type, user, sortName, cancellationToken);
}
- public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
+ public Task<UserView> GetUserView(string type, string sortName, CancellationToken cancellationToken)
{
- return GetUserView(null, type, user, sortName, cancellationToken);
+ var name = _localizationManager.GetLocalizedString("ViewType" + type);
+
+ return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
}
}
}