mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-17 07:36:37 +00:00
Cleanup/simplification
* Removed useless copies/allocations * Reduced unneeded complexity
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Emby.Server.Implementations.Images;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
@@ -20,7 +19,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
{
|
||||
}
|
||||
|
||||
protected override List<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
var view = (CollectionFolder)item;
|
||||
var viewType = view.CollectionType;
|
||||
@@ -56,7 +55,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
includeItemTypes = new string[] { "Video", "Audio", "Photo", "Movie", "Series" };
|
||||
}
|
||||
|
||||
var recursive = !new[] { CollectionType.Playlists }.Contains(view.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
||||
var recursive = !string.Equals(CollectionType.Playlists, viewType, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return view.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
@@ -71,7 +70,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
},
|
||||
IncludeItemTypes = includeItemTypes
|
||||
|
||||
}).ToList();
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool Supports(BaseItem item)
|
||||
@@ -79,7 +78,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
return item is CollectionFolder;
|
||||
}
|
||||
|
||||
protected override string CreateImage(BaseItem item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
protected override List<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
var view = (UserView)item;
|
||||
|
||||
@@ -46,8 +46,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
|
||||
var items = result.Select(i =>
|
||||
{
|
||||
var episode = i as Episode;
|
||||
if (episode != null)
|
||||
if (i is Episode episode)
|
||||
{
|
||||
var series = episode.Series;
|
||||
if (series != null)
|
||||
@@ -58,8 +57,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
return episode;
|
||||
}
|
||||
|
||||
var season = i as Season;
|
||||
if (season != null)
|
||||
if (i is Season season)
|
||||
{
|
||||
var series = season.Series;
|
||||
if (series != null)
|
||||
@@ -70,8 +68,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
return season;
|
||||
}
|
||||
|
||||
var audio = i as Audio;
|
||||
if (audio != null)
|
||||
if (i is Audio audio)
|
||||
{
|
||||
var album = audio.AlbumEntity;
|
||||
if (album != null && album.HasImage(ImageType.Primary))
|
||||
@@ -122,7 +119,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty);
|
||||
}
|
||||
|
||||
protected override string CreateImage(BaseItem item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
if (itemsWithImages.Count == 0)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
protected override List<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
||||
{
|
||||
return _libraryManager.GetItemList(new InternalItemsQuery
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace Emby.Server.Implementations.UserViews
|
||||
});
|
||||
}
|
||||
|
||||
protected override string CreateImage(BaseItem item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user