aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/UserViewManager.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2023-11-09 22:03:55 -0700
committerGitHub <noreply@github.com>2023-11-09 22:03:55 -0700
commit892973a9e372000ad7babe2381e4e83b39591951 (patch)
treefc408136c09e6377309629ad6b2d4b2b26ff3c3f /Emby.Server.Implementations/Library/UserViewManager.cs
parent35bd0c00c965176d6ddb167605ed3a3eba9a4524 (diff)
parent44b771bfb4b6412360b18c80621c90902c0a43a7 (diff)
Merge branch 'master' into media-type
Diffstat (limited to 'Emby.Server.Implementations/Library/UserViewManager.cs')
-rw-r--r--Emby.Server.Implementations/Library/UserViewManager.cs35
1 files changed, 17 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs
index 0343db68b..113370fc3 100644
--- a/Emby.Server.Implementations/Library/UserViewManager.cs
+++ b/Emby.Server.Implementations/Library/UserViewManager.cs
@@ -8,7 +8,6 @@ using System.Linq;
using System.Threading;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
-using Jellyfin.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
@@ -64,8 +63,8 @@ namespace Emby.Server.Implementations.Library
var collectionFolder = folder as ICollectionFolder;
var folderViewType = collectionFolder?.CollectionType;
- // Playlist library requires special handling because the folder only refrences user playlists
- if (string.Equals(folderViewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))
+ // Playlist library requires special handling because the folder only references user playlists
+ if (folderViewType == CollectionType.Playlists)
{
var items = folder.GetItemList(new InternalItemsQuery(user)
{
@@ -90,7 +89,7 @@ namespace Emby.Server.Implementations.Library
continue;
}
- if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparison.OrdinalIgnoreCase))
+ if (query.PresetViews.Contains(folderViewType))
{
list.Add(GetUserView(folder, folderViewType, string.Empty));
}
@@ -102,14 +101,14 @@ namespace Emby.Server.Implementations.Library
foreach (var viewType in new[] { CollectionType.Movies, CollectionType.TvShows })
{
- var parents = groupedFolders.Where(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(i.CollectionType))
+ var parents = groupedFolders.Where(i => i.CollectionType == viewType || i.CollectionType is null)
.ToList();
if (parents.Count > 0)
{
- var localizationKey = string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ?
- "TvShows" :
- "Movies";
+ var localizationKey = viewType == CollectionType.TvShows
+ ? "TvShows"
+ : "Movies";
list.Add(GetUserView(parents, viewType, localizationKey, string.Empty, user, query.PresetViews));
}
@@ -164,14 +163,14 @@ namespace Emby.Server.Implementations.Library
.ToArray();
}
- public UserView GetUserSubViewWithName(string name, Guid parentId, string type, string sortName)
+ public UserView GetUserSubViewWithName(string name, Guid parentId, CollectionType? type, string sortName)
{
var uniqueId = parentId + "subview" + type;
return _libraryManager.GetNamedView(name, parentId, type, sortName, uniqueId);
}
- public UserView GetUserSubView(Guid parentId, string type, string localizationKey, string sortName)
+ public UserView GetUserSubView(Guid parentId, CollectionType? type, string localizationKey, string sortName)
{
var name = _localizationManager.GetLocalizedString(localizationKey);
@@ -180,15 +179,15 @@ namespace Emby.Server.Implementations.Library
private Folder GetUserView(
List<ICollectionFolder> parents,
- string viewType,
+ CollectionType? viewType,
string localizationKey,
string sortName,
User user,
- string[] presetViews)
+ CollectionType?[] presetViews)
{
- if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase)))
+ if (parents.Count == 1 && parents.All(i => i.CollectionType == viewType))
{
- if (!presetViews.Contains(viewType, StringComparison.OrdinalIgnoreCase))
+ if (!presetViews.Contains(viewType))
{
return (Folder)parents[0];
}
@@ -200,7 +199,7 @@ namespace Emby.Server.Implementations.Library
return _libraryManager.GetNamedView(user, name, viewType, sortName);
}
- public UserView GetUserView(Folder parent, string viewType, string sortName)
+ public UserView GetUserView(Folder parent, CollectionType? viewType, string sortName)
{
return _libraryManager.GetShadowView(parent, viewType, sortName);
}
@@ -280,7 +279,7 @@ namespace Emby.Server.Implementations.Library
var isPlayed = request.IsPlayed;
- if (parents.OfType<ICollectionFolder>().Any(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)))
+ if (parents.OfType<ICollectionFolder>().Any(i => i.CollectionType == CollectionType.Music))
{
isPlayed = null;
}
@@ -306,11 +305,11 @@ namespace Emby.Server.Implementations.Library
var hasCollectionType = parents.OfType<UserView>().ToArray();
if (hasCollectionType.Length > 0)
{
- if (hasCollectionType.All(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)))
+ if (hasCollectionType.All(i => i.CollectionType == CollectionType.Movies))
{
includeItemTypes = new[] { BaseItemKind.Movie };
}
- else if (hasCollectionType.All(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)))
+ else if (hasCollectionType.All(i => i.CollectionType == CollectionType.TvShows))
{
includeItemTypes = new[] { BaseItemKind.Episode };
}