From c90cdef3ba630707d16c63dc4392fcc54bcf122d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 15 Apr 2015 17:59:20 -0400 Subject: [PATCH] added user view setting --- MediaBrowser.Api/MediaBrowser.Api.csproj | 1 + MediaBrowser.Api/StartupWizardService.cs | 1 + .../UserLibrary/UserLibraryService.cs | 45 ------ .../UserLibrary/UserViewsService.cs | 121 ++++++++++++++ .../Entities/ICollectionFolder.cs | 5 +- .../Entities/UserViewBuilder.cs | 11 +- .../Configuration/ServerConfiguration.cs | 7 +- .../Configuration/UserConfiguration.cs | 2 + .../FolderImages/DefaultImageProvider.cs | 153 ------------------ .../MediaBrowser.Providers.csproj | 1 - .../Library/LibraryManager.cs | 11 +- .../Library/UserViewManager.cs | 104 ++++++++---- .../Localization/Server/server.json | 5 +- .../Sync/CloudSyncProfile.cs | 2 +- SharedVersion.cs | 4 +- 15 files changed, 234 insertions(+), 239 deletions(-) create mode 100644 MediaBrowser.Api/UserLibrary/UserViewsService.cs delete mode 100644 MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 14d0f13fb..ab205d6eb 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -156,6 +156,7 @@ + diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 4655f2c6f..edcce10d2 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -66,6 +66,7 @@ namespace MediaBrowser.Api _config.Configuration.EnableStandaloneMetadata = true; _config.Configuration.EnableLibraryMetadataSubFolder = true; _config.Configuration.EnableUserSpecificUserViews = true; + _config.Configuration.EnableUserSpecificUserViews2 = true; _config.SaveConfiguration(); } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 38eae2577..aa6e227d8 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -38,20 +38,6 @@ namespace MediaBrowser.Api.UserLibrary public string Id { get; set; } } - [Route("/Users/{UserId}/Views", "GET")] - public class GetUserViews : IReturn> - { - /// - /// Gets or sets the user id. - /// - /// The user id. - [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] - public string UserId { get; set; } - - [ApiMember(Name = "IncludeExternalContent", Description = "Whether or not to include external views such as channels or live tv", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")] - public bool? IncludeExternalContent { get; set; } - } - /// /// Class GetItem /// @@ -345,37 +331,6 @@ namespace MediaBrowser.Api.UserLibrary return ToOptimizedResult(dtos.ToList()); } - public async Task Get(GetUserViews request) - { - var user = _userManager.GetUserById(request.UserId); - - var query = new UserViewQuery - { - UserId = request.UserId - - }; - - if (request.IncludeExternalContent.HasValue) - { - query.IncludeExternalContent = request.IncludeExternalContent.Value; - } - - var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false); - - var dtoOptions = GetDtoOptions(request); - - var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)) - .ToArray(); - - var result = new QueryResult - { - Items = dtos, - TotalRecordCount = dtos.Length - }; - - return ToOptimizedResult(result); - } - private List GetAsync(GetSpecialFeatures request) { var user = _userManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/UserLibrary/UserViewsService.cs b/MediaBrowser.Api/UserLibrary/UserViewsService.cs new file mode 100644 index 000000000..9b00b42f7 --- /dev/null +++ b/MediaBrowser.Api/UserLibrary/UserViewsService.cs @@ -0,0 +1,121 @@ +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Library; +using MediaBrowser.Model.Querying; +using ServiceStack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Api.UserLibrary +{ + [Route("/Users/{UserId}/Views", "GET")] + public class GetUserViews : IReturn> + { + /// + /// Gets or sets the user id. + /// + /// The user id. + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UserId { get; set; } + + [ApiMember(Name = "IncludeExternalContent", Description = "Whether or not to include external views such as channels or live tv", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")] + public bool? IncludeExternalContent { get; set; } + } + + [Route("/Users/{UserId}/SpecialViewOptions", "GET")] + public class GetSpecialViewOptions : IReturn> + { + /// + /// Gets or sets the user id. + /// + /// The user id. + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string UserId { get; set; } + } + + public class UserViewsService : BaseApiService + { + private readonly IUserManager _userManager; + private readonly IUserViewManager _userViewManager; + private readonly IDtoService _dtoService; + + public UserViewsService(IUserManager userManager, IUserViewManager userViewManager, IDtoService dtoService) + { + _userManager = userManager; + _userViewManager = userViewManager; + _dtoService = dtoService; + } + + public async Task Get(GetUserViews request) + { + var query = new UserViewQuery + { + UserId = request.UserId + }; + + if (request.IncludeExternalContent.HasValue) + { + query.IncludeExternalContent = request.IncludeExternalContent.Value; + } + + var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false); + + var dtoOptions = GetDtoOptions(request); + + var user = _userManager.GetUserById(request.UserId); + + var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)) + .ToArray(); + + var result = new QueryResult + { + Items = dtos, + TotalRecordCount = dtos.Length + }; + + return ToOptimizedResult(result); + } + + public async Task Get(GetSpecialViewOptions request) + { + var user = _userManager.GetUserById(request.UserId); + + var views = user.RootFolder + .GetChildren(user, true) + .OfType() + .Where(i => IsEligibleForSpecialView(i)) + .ToList(); + + var list = views + .Select(i => new SpecialViewOption + { + Name = i.Name, + Id = i.Id.ToString("N") + + }) + .OrderBy(i => i.Name) + .ToList(); + + return ToOptimizedResult(list); + } + + private bool IsEligibleForSpecialView(CollectionFolder view) + { + var types = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Games, CollectionType.Music }; + + return types.Contains(view.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase); + } + } + + class SpecialViewOption + { + public string Name { get; set; } + public string Id { get; set; } + } +} diff --git a/MediaBrowser.Controller/Entities/ICollectionFolder.cs b/MediaBrowser.Controller/Entities/ICollectionFolder.cs index 656aa37ce..f46d7ed6f 100644 --- a/MediaBrowser.Controller/Entities/ICollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/ICollectionFolder.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace MediaBrowser.Controller.Entities { @@ -9,6 +10,8 @@ namespace MediaBrowser.Controller.Entities { string CollectionType { get; } string Path { get; } + string Name { get; } + Guid Id { get; } IEnumerable PhysicalLocations { get; } } } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 63ce223af..a6d123fe8 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -247,7 +247,16 @@ namespace MediaBrowser.Controller.Entities return GetFavoriteSongs(queryParent, user, query); default: - return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), queryParent, query); + { + if (queryParent is UserView) + { + return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), queryParent, query); + } + else + { + return GetResult(queryParent.GetChildren(user, true), queryParent, query); + } + } } } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index ac9bd6b08..0808a79ab 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -49,7 +49,12 @@ namespace MediaBrowser.Model.Configuration /// /// true if [enable user specific user views]; otherwise, false. public bool EnableUserSpecificUserViews { get; set; } - + /// + /// Gets or sets a value indicating whether [enable user specific user views2]. + /// + /// true if [enable user specific user views2]; otherwise, false. + public bool EnableUserSpecificUserViews2 { get; set; } + /// /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. /// diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index 9cd8c1067..9a76c69f6 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -46,6 +46,7 @@ namespace MediaBrowser.Model.Configuration public bool EnableCinemaMode { get; set; } public string[] LatestItemsExcludes { get; set; } + public string[] PlainFolderViews { get; set; } public bool HidePlayedInLatest { get; set; } @@ -62,6 +63,7 @@ namespace MediaBrowser.Model.Configuration DisplayChannelsWithinViews = new string[] { }; ExcludeFoldersFromGrouping = new string[] { }; + PlainFolderViews = new string[] { }; DisplayCollectionsView = true; IncludeTrailersInSuggestions = true; diff --git a/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs b/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs deleted file mode 100644 index 3550ee688..000000000 --- a/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs +++ /dev/null @@ -1,153 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Providers; -using MediaBrowser.Providers.Genres; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Providers.FolderImages -{ - public class DefaultImageProvider : IRemoteImageProvider, IHasItemChangeMonitor, IHasOrder - { - private readonly IHttpClient _httpClient; - - public DefaultImageProvider(IHttpClient httpClient) - { - _httpClient = httpClient; - } - - public IEnumerable GetSupportedImages(IHasImages item) - { - return new List - { - ImageType.Primary, - ImageType.Thumb - }; - } - - public Task> GetImages(IHasImages item, CancellationToken cancellationToken) - { - var view = item as UserView; - - if (view != null) - { - return GetImages(view.ViewType, view.ParentId != Guid.Empty, cancellationToken); - } - - var folder = (ICollectionFolder)item; - return GetImages(folder.CollectionType, false, cancellationToken); - } - - private Task> GetImages(string viewType, bool isSubView, CancellationToken cancellationToken) - { - var url = GetImageUrl(viewType, isSubView); - var list = new List(); - - if (!string.IsNullOrWhiteSpace(url)) - { - list.AddRange(new List - { - new RemoteImageInfo - { - ProviderName = Name, - Url = url, - Type = ImageType.Primary - }, - - new RemoteImageInfo - { - ProviderName = Name, - Url = url, - Type = ImageType.Thumb - } - }); - } - - return Task.FromResult>(list); - } - - private string GetImageUrl(string viewType, bool isSubView) - { - const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/MediaBrowser.Resources/master/images/folders/"; - - if (string.Equals(viewType, CollectionType.Books, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - - if (isSubView) - { - return null; - } - - return urlPrefix + "generic.png"; - } - - public string Name - { - get { return "Default Image Provider"; } - } - - public bool Supports(IHasImages item) - { - return item is ICollectionFolder || item is UserView; - } - - public Task GetImageResponse(string url, CancellationToken cancellationToken) - { - return _httpClient.GetResponse(new HttpRequestOptions - { - CancellationToken = cancellationToken, - Url = url, - ResourcePool = GenreImageProvider.ImageDownloadResourcePool - }); - } - - public bool HasChanged(IHasMetadata item, MetadataStatus status, IDirectoryService directoryService) - { - return GetSupportedImages(item).Any(i => !item.HasImage(i)); - } - - public int Order - { - get - { - // Run after the dynamic image provider - return 1; - } - } - } -} diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index 09951b29d..444567afa 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -83,7 +83,6 @@ - diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 02c16d0d4..8285fb7e5 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1678,11 +1678,6 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentNullException("name"); } - if (string.IsNullOrWhiteSpace(viewType)) - { - throw new ArgumentNullException("viewType"); - } - var id = GetNewItemId("37_namedview_" + name + user.Id.ToString("N") + (parentId ?? string.Empty), typeof(UserView)); var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N")); @@ -1716,6 +1711,12 @@ namespace MediaBrowser.Server.Implementations.Library isNew = true; } + if (!string.Equals(viewType, item.ViewType, StringComparison.OrdinalIgnoreCase)) + { + item.ViewType = viewType; + await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); + } + var refresh = isNew || (DateTime.UtcNow - item.DateLastSaved).TotalHours >= 12; if (refresh) diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index 757f08562..e5a8a3fa0 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -53,6 +53,7 @@ namespace MediaBrowser.Server.Implementations.Library .ToList(); var excludeFolderIds = user.Configuration.ExcludeFoldersFromGrouping.Select(i => new Guid(i)).ToList(); + var plainFolderIds = user.Configuration.PlainFolderViews.Select(i => new Guid(i)).ToList(); var standaloneFolders = folders .Where(i => UserView.IsExcludedFromGrouping(i) || excludeFolderIds.Contains(i.Id)) @@ -72,13 +73,17 @@ namespace MediaBrowser.Server.Implementations.Library var collectionFolder = folder as ICollectionFolder; var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType; - if (string.IsNullOrWhiteSpace(folderViewType)) + if (plainFolderIds.Contains(folder.Id)) { - list.Add(folder); + list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false)); + } + else if (!string.IsNullOrWhiteSpace(folderViewType)) + { + list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false)); } else { - list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(folder); } } } @@ -87,44 +92,57 @@ namespace MediaBrowser.Server.Implementations.Library list.AddRange(standaloneFolders); } - if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) || - foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType))) + var parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType)) + .ToList(); + + if (parents.Count > 0) { - list.Add(await GetUserView(CollectionType.TvShows, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, CollectionType.TvShows, string.Empty, user, cancellationToken).ConfigureAwait(false)); } - if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) || - foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))) + parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) || string.Equals(i.CollectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType)) + .ToList(); + + if (parents.Count > 0) { - list.Add(await GetUserView(CollectionType.Music, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, CollectionType.Music, string.Empty, user, cancellationToken).ConfigureAwait(false)); } - if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) || - foldersWithViewTypes.Any(i => string.IsNullOrWhiteSpace(i.CollectionType))) + parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType)) + .ToList(); + + if (parents.Count > 0) { - list.Add(await GetUserView(CollectionType.Movies, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, CollectionType.Movies, string.Empty, user, cancellationToken).ConfigureAwait(false)); } - if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase))) + parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)) + .ToList(); + + if (parents.Count > 0) { - list.Add(await GetUserView(CollectionType.Games, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, CollectionType.Games, string.Empty, user, cancellationToken).ConfigureAwait(false)); } - if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))) + parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) + .ToList(); + + if (parents.Count > 0) { - //list.Add(_collectionManager.GetCollectionsFolder(user.Id.ToString("N"))); - list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, CollectionType.BoxSets, string.Empty, user, cancellationToken).ConfigureAwait(false)); } - if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))) + parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) + .ToList(); + + if (parents.Count > 0) { - //list.Add(_playlists.GetPlaylistsFolder(user.Id.ToString("N"))); - list.Add(await GetUserView(CollectionType.Playlists, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(parents, CollectionType.Playlists, string.Empty, user, cancellationToken).ConfigureAwait(false)); } if (user.Configuration.DisplayFoldersView) { - list.Add(await GetUserView(CollectionType.Folders, "zz_" + CollectionType.Folders, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(new List(), CollectionType.Folders, "zz_" + CollectionType.Folders, user, cancellationToken).ConfigureAwait(false)); } if (query.IncludeExternalContent) @@ -151,7 +169,7 @@ namespace MediaBrowser.Server.Implementations.Library if (_liveTvManager.GetEnabledUsers().Select(i => i.Id.ToString("N")).Contains(query.UserId)) { //list.Add(await _liveTvManager.GetInternalLiveTvFolder(query.UserId, cancellationToken).ConfigureAwait(false)); - list.Add(await GetUserView(CollectionType.LiveTv, string.Empty, user, cancellationToken).ConfigureAwait(false)); + list.Add(await GetUserView(new List(), CollectionType.LiveTv, string.Empty, user, cancellationToken).ConfigureAwait(false)); } } @@ -182,16 +200,46 @@ namespace MediaBrowser.Server.Implementations.Library return GetUserSubView(name, parentId, type, user, sortName, cancellationToken); } - public Task GetUserView(string type, string sortName, User user, CancellationToken cancellationToken) + public async Task GetUserView(List parents, string viewType, string sortName, User user, CancellationToken cancellationToken) { - var name = _localizationManager.GetLocalizedString("ViewType" + type); + if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase))) + { + var name = parents[0].Name; + var parentId = parents[0].Id; - return _libraryManager.GetNamedView(user, name, type, sortName, cancellationToken); + var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase); + + if (_config.Configuration.EnableUserSpecificUserViews2) + { + return await GetUserView(parentId, name, viewType, enableRichView, string.Empty, user, cancellationToken).ConfigureAwait(false); + } + + if (_config.Configuration.EnableUserSpecificUserViews) + { + viewType = enableRichView ? viewType : null; + var view = await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); + + if (view.ParentId != parentId) + { + view.ParentId = parentId; + await view.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); + } + return view; + } + + return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); + } + else + { + var name = _localizationManager.GetLocalizedString("ViewType" + viewType); + + return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); + } } - public Task GetUserView(Guid parentId, string name, string type, string sortName, User user, CancellationToken cancellationToken) + public Task GetUserView(Guid parentId, string name, string viewType, bool enableRichView, string sortName, User user, CancellationToken cancellationToken) { - return _libraryManager.GetNamedView(user, name, parentId.ToString("N"), type, sortName, cancellationToken); + return _libraryManager.GetNamedView(user, name, parentId.ToString("N"), viewType, sortName, cancellationToken); } public List>> GetLatestItems(LatestItemsQuery request) @@ -317,7 +365,7 @@ namespace MediaBrowser.Server.Implementations.Library .RootFolder .GetRecursiveChildren(filter); } - + private IEnumerable GetItemsConfiguredForLatest(User user, Func filter) { // Avoid implicitly captured closure diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index bfd23243a..2b9ad3d99 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -1430,5 +1430,8 @@ "ButtonMyPreferencesWelcomeNo": "No thanks, I'll do it later.", "MyPreferencesWelcomeMessage1": "We've presented your library in a way we think you'll enjoy. The appearance and grouping of content can be changed anytime by adjusting your preferences. Your preferences will apply to all Emby apps.", "MyPreferencesWelcomeMessage2": "Would you like to set your preferences now?", - "ToAccessPreferencesHelp": "To access your preferences later, click your user icon in the top right header and select My Preferences." + "ToAccessPreferencesHelp": "To access your preferences later, click your user icon in the top right header and select My Preferences.", + "HeaderViewStyles": "View Styles", + "LabelSelectViewStyles": "Enable rich presentations for:", + "LabelSelectViewStylesHelp": "If enabled, views will be built with metadata to offer categories such as Suggestions, Latest, Genres, and more. If disabled, they'll be displayed with plain folders." } diff --git a/MediaBrowser.Server.Implementations/Sync/CloudSyncProfile.cs b/MediaBrowser.Server.Implementations/Sync/CloudSyncProfile.cs index 90135acfe..992f1d16c 100644 --- a/MediaBrowser.Server.Implementations/Sync/CloudSyncProfile.cs +++ b/MediaBrowser.Server.Implementations/Sync/CloudSyncProfile.cs @@ -205,7 +205,7 @@ namespace MediaBrowser.Server.Implementations.Sync { Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, - Value = "5", + Value = "6", IsRequired = false }, new ProfileCondition diff --git a/SharedVersion.cs b/SharedVersion.cs index 75ef623e9..9660d919f 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5582.1")] +[assembly: AssemblyVersion("3.0.*")] +//[assembly: AssemblyVersion("3.0.5582.1")]