From 8f1899906b747b09ef9356d932e65f2257115734 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 15 Oct 2015 13:37:27 -0400 Subject: [PATCH] show library folder images --- .../Entities/VirtualFolderInfo.cs | 6 ++++ .../Library/LibraryManager.cs | 34 ++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs index d440f97bd0..b7f92e9ec7 100644 --- a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs +++ b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs @@ -32,5 +32,11 @@ namespace MediaBrowser.Model.Entities { Locations = new List(); } + + /// + /// Gets or sets the primary image item identifier. + /// + /// The primary image item identifier. + public string PrimaryImageItemId { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 06b9ecabe8..ce2dbb5261 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1171,18 +1171,34 @@ namespace MediaBrowser.Server.Implementations.Library /// IEnumerable{VirtualFolderInfo}. private IEnumerable GetView(string path) { + var topLibraryFolders = GetUserRootFolder().Children.ToList(); + return _fileSystem.GetDirectoryPaths(path) - .Select(dir => new VirtualFolderInfo - { - Name = Path.GetFileName(dir), + .Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders)); + } - Locations = Directory.EnumerateFiles(dir, "*.mblink", SearchOption.TopDirectoryOnly) - .Select(_fileSystem.ResolveShortcut) - .OrderBy(i => i) - .ToList(), + private VirtualFolderInfo GetVirtualFolderInfo(string dir, List collectionFolders) + { + var info = new VirtualFolderInfo + { + Name = Path.GetFileName(dir), - CollectionType = GetCollectionType(dir) - }); + Locations = Directory.EnumerateFiles(dir, "*.mblink", SearchOption.TopDirectoryOnly) + .Select(_fileSystem.ResolveShortcut) + .OrderBy(i => i) + .ToList(), + + CollectionType = GetCollectionType(dir) + }; + + var libraryFolder = collectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); + + if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary)) + { + info.PrimaryImageItemId = libraryFolder.Id.ToString("N"); + } + + return info; } private string GetCollectionType(string path)