update collection grouping setting

pull/702/head
Luke Pulverenti 9 years ago
parent aa5262de21
commit 2e040f9c0c

@ -875,7 +875,7 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
if (UserViewBuilder.CollapseBoxSetItems(query, this, query.User)) if (UserViewBuilder.CollapseBoxSetItems(query, this, query.User, ConfigurationManager))
{ {
Logger.Debug("Query requires post-filtering due to CollapseBoxSetItems"); Logger.Debug("Query requires post-filtering due to CollapseBoxSetItems");
return true; return true;
@ -983,7 +983,7 @@ namespace MediaBrowser.Controller.Entities
protected QueryResult<BaseItem> PostFilterAndSort(IEnumerable<BaseItem> items, InternalItemsQuery query) protected QueryResult<BaseItem> PostFilterAndSort(IEnumerable<BaseItem> items, InternalItemsQuery query)
{ {
return UserViewBuilder.PostFilterAndSort(items, this, null, query, LibraryManager); return UserViewBuilder.PostFilterAndSort(items, this, null, query, LibraryManager, ConfigurationManager);
} }
public virtual IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) public virtual IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)

@ -58,7 +58,7 @@ namespace MediaBrowser.Controller.Entities
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent; parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
} }
return new UserViewBuilder(UserViewManager, LiveTvManager, ChannelManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, CollectionManager, PlaylistManager) return new UserViewBuilder(UserViewManager, LiveTvManager, ChannelManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, ConfigurationManager, PlaylistManager)
.GetUserItems(parent, this, ViewType, query); .GetUserItems(parent, this, ViewType, query);
} }

@ -18,6 +18,8 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -30,10 +32,10 @@ namespace MediaBrowser.Controller.Entities
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IUserDataManager _userDataManager; private readonly IUserDataManager _userDataManager;
private readonly ITVSeriesManager _tvSeriesManager; private readonly ITVSeriesManager _tvSeriesManager;
private readonly ICollectionManager _collectionManager; private readonly IServerConfigurationManager _config;
private readonly IPlaylistManager _playlistManager; private readonly IPlaylistManager _playlistManager;
public UserViewBuilder(IUserViewManager userViewManager, ILiveTvManager liveTvManager, IChannelManager channelManager, ILibraryManager libraryManager, ILogger logger, IUserDataManager userDataManager, ITVSeriesManager tvSeriesManager, ICollectionManager collectionManager, IPlaylistManager playlistManager) public UserViewBuilder(IUserViewManager userViewManager, ILiveTvManager liveTvManager, IChannelManager channelManager, ILibraryManager libraryManager, ILogger logger, IUserDataManager userDataManager, ITVSeriesManager tvSeriesManager, IServerConfigurationManager config, IPlaylistManager playlistManager)
{ {
_userViewManager = userViewManager; _userViewManager = userViewManager;
_liveTvManager = liveTvManager; _liveTvManager = liveTvManager;
@ -42,7 +44,7 @@ namespace MediaBrowser.Controller.Entities
_logger = logger; _logger = logger;
_userDataManager = userDataManager; _userDataManager = userDataManager;
_tvSeriesManager = tvSeriesManager; _tvSeriesManager = tvSeriesManager;
_collectionManager = collectionManager; _config = config;
_playlistManager = playlistManager; _playlistManager = playlistManager;
} }
@ -159,7 +161,7 @@ namespace MediaBrowser.Controller.Entities
return await GetTvGenres(queryParent, user, query).ConfigureAwait(false); return await GetTvGenres(queryParent, user, query).ConfigureAwait(false);
case SpecialFolder.TvGenre: case SpecialFolder.TvGenre:
return await GetTvGenreItems(queryParent, displayParent, user, query).ConfigureAwait(false); return GetTvGenreItems(queryParent, displayParent, user, query);
case SpecialFolder.TvResume: case SpecialFolder.TvResume:
return GetTvResume(queryParent, user, query); return GetTvResume(queryParent, user, query);
@ -740,7 +742,7 @@ namespace MediaBrowser.Controller.Entities
return GetResult(genres, parent, query); return GetResult(genres, parent, query);
} }
private async Task<QueryResult<BaseItem>> GetTvGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query) private QueryResult<BaseItem> GetTvGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query)
{ {
query.Recursive = true; query.Recursive = true;
query.ParentId = queryParent.Id; query.ParentId = queryParent.Id;
@ -769,7 +771,7 @@ namespace MediaBrowser.Controller.Entities
{ {
items = items.Where(i => Filter(i, query.User, query, _userDataManager, _libraryManager)); items = items.Where(i => Filter(i, query.User, query, _userDataManager, _libraryManager));
return PostFilterAndSort(items, queryParent, null, query, _libraryManager); return PostFilterAndSort(items, queryParent, null, query, _libraryManager, _config);
} }
public static bool FilterItem(BaseItem item, InternalItemsQuery query) public static bool FilterItem(BaseItem item, InternalItemsQuery query)
@ -782,14 +784,15 @@ namespace MediaBrowser.Controller.Entities
int? totalRecordLimit, int? totalRecordLimit,
InternalItemsQuery query) InternalItemsQuery query)
{ {
return PostFilterAndSort(items, queryParent, totalRecordLimit, query, _libraryManager); return PostFilterAndSort(items, queryParent, totalRecordLimit, query, _libraryManager, _config);
} }
public static QueryResult<BaseItem> PostFilterAndSort(IEnumerable<BaseItem> items, public static QueryResult<BaseItem> PostFilterAndSort(IEnumerable<BaseItem> items,
BaseItem queryParent, BaseItem queryParent,
int? totalRecordLimit, int? totalRecordLimit,
InternalItemsQuery query, InternalItemsQuery query,
ILibraryManager libraryManager) ILibraryManager libraryManager,
IServerConfigurationManager configurationManager)
{ {
var user = query.User; var user = query.User;
@ -798,7 +801,7 @@ namespace MediaBrowser.Controller.Entities
query.IsVirtualUnaired, query.IsVirtualUnaired,
query.IsUnaired); query.IsUnaired);
items = CollapseBoxSetItemsIfNeeded(items, query, queryParent, user); items = CollapseBoxSetItemsIfNeeded(items, query, queryParent, user, configurationManager);
// This must be the last filter // This must be the last filter
if (!string.IsNullOrEmpty(query.AdjacentTo)) if (!string.IsNullOrEmpty(query.AdjacentTo))
@ -812,14 +815,15 @@ namespace MediaBrowser.Controller.Entities
public static IEnumerable<BaseItem> CollapseBoxSetItemsIfNeeded(IEnumerable<BaseItem> items, public static IEnumerable<BaseItem> CollapseBoxSetItemsIfNeeded(IEnumerable<BaseItem> items,
InternalItemsQuery query, InternalItemsQuery query,
BaseItem queryParent, BaseItem queryParent,
User user) User user,
IServerConfigurationManager configurationManager)
{ {
if (items == null) if (items == null)
{ {
throw new ArgumentNullException("items"); throw new ArgumentNullException("items");
} }
if (CollapseBoxSetItems(query, queryParent, user)) if (CollapseBoxSetItems(query, queryParent, user, configurationManager))
{ {
items = BaseItem.CollectionManager.CollapseItemsWithinBoxSets(items, user); items = BaseItem.CollectionManager.CollapseItemsWithinBoxSets(items, user);
} }
@ -852,7 +856,8 @@ namespace MediaBrowser.Controller.Entities
public static bool CollapseBoxSetItems(InternalItemsQuery query, public static bool CollapseBoxSetItems(InternalItemsQuery query,
BaseItem queryParent, BaseItem queryParent,
User user) User user,
IServerConfigurationManager configurationManager)
{ {
// Could end up stuck in a loop like this // Could end up stuck in a loop like this
if (queryParent is BoxSet) if (queryParent is BoxSet)
@ -864,7 +869,7 @@ namespace MediaBrowser.Controller.Entities
if (!param.HasValue) if (!param.HasValue)
{ {
if (user != null && !user.Configuration.GroupMoviesIntoBoxSets) if (user != null && !configurationManager.Configuration.EnableGroupingIntoCollections)
{ {
return false; return false;
} }

@ -199,6 +199,7 @@ namespace MediaBrowser.Model.Configuration
public bool EnableStandaloneMusicKeys { get; set; } public bool EnableStandaloneMusicKeys { get; set; }
public bool EnableLocalizedGuids { get; set; } public bool EnableLocalizedGuids { get; set; }
public bool EnableFolderView { get; set; } public bool EnableFolderView { get; set; }
public bool EnableGroupingIntoCollections { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.

@ -60,7 +60,6 @@ namespace MediaBrowser.Server.Implementations.Connect
{ {
return new ConnectUserPreferences return new ConnectUserPreferences
{ {
GroupMoviesIntoBoxSets = config.GroupMoviesIntoBoxSets,
PlayDefaultAudioTrack = config.PlayDefaultAudioTrack, PlayDefaultAudioTrack = config.PlayDefaultAudioTrack,
SubtitleMode = config.SubtitleMode, SubtitleMode = config.SubtitleMode,
PreferredAudioLanguages = string.IsNullOrWhiteSpace(config.AudioLanguagePreference) ? new string[] { } : new[] { config.AudioLanguagePreference }, PreferredAudioLanguages = string.IsNullOrWhiteSpace(config.AudioLanguagePreference) ? new string[] { } : new[] { config.AudioLanguagePreference },

@ -71,6 +71,7 @@
<Compile Include="FFMpeg\FFmpegValidator.cs" /> <Compile Include="FFMpeg\FFmpegValidator.cs" />
<Compile Include="INativeApp.cs" /> <Compile Include="INativeApp.cs" />
<Compile Include="MbLinkShortcutHandler.cs" /> <Compile Include="MbLinkShortcutHandler.cs" />
<Compile Include="Migrations\CollectionGroupingMigration.cs" />
<Compile Include="Migrations\FolderViewSettingMigration.cs" /> <Compile Include="Migrations\FolderViewSettingMigration.cs" />
<Compile Include="Migrations\IVersionMigration.cs" /> <Compile Include="Migrations\IVersionMigration.cs" />
<Compile Include="Migrations\DbMigration.cs" /> <Compile Include="Migrations\DbMigration.cs" />

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public class CollectionGroupingMigration : IVersionMigration
{
private readonly IServerConfigurationManager _config;
private readonly IUserManager _userManager;
public CollectionGroupingMigration(IServerConfigurationManager config, IUserManager userManager)
{
_config = config;
_userManager = userManager;
}
public void Run()
{
var migrationKey = this.GetType().Name;
var migrationKeyList = _config.Configuration.Migrations.ToList();
if (!migrationKeyList.Contains(migrationKey))
{
if (_config.Configuration.IsStartupWizardCompleted)
{
if (_userManager.Users.Any(i => i.Configuration.GroupMoviesIntoBoxSets))
{
_config.Configuration.EnableGroupingIntoCollections = true;
}
}
migrationKeyList.Add(migrationKey);
_config.Configuration.Migrations = migrationKeyList.ToArray();
_config.SaveConfiguration();
}
}
}
}
Loading…
Cancel
Save