update views
This commit is contained in:
parent
736d87fd7e
commit
904175ce26
|
@ -70,9 +70,7 @@ namespace MediaBrowser.Api
|
||||||
_config.Configuration.EnableStandaloneMetadata = true;
|
_config.Configuration.EnableStandaloneMetadata = true;
|
||||||
_config.Configuration.EnableLibraryMetadataSubFolder = true;
|
_config.Configuration.EnableLibraryMetadataSubFolder = true;
|
||||||
_config.Configuration.EnableCustomPathSubFolders = true;
|
_config.Configuration.EnableCustomPathSubFolders = true;
|
||||||
_config.Configuration.EnableUserViews = true;
|
|
||||||
_config.Configuration.EnableDateLastRefresh = true;
|
_config.Configuration.EnableDateLastRefresh = true;
|
||||||
_config.Configuration.EnableSharedCollectionViewImage = true;
|
|
||||||
_config.SaveConfiguration();
|
_config.SaveConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
var views = user.RootFolder
|
var views = user.RootFolder
|
||||||
.GetChildren(user, true)
|
.GetChildren(user, true)
|
||||||
.OfType<Folder>()
|
.OfType<Folder>()
|
||||||
.Where(i => !UserView.IsExcludedFromGrouping(i))
|
.Where(UserView.IsEligibleForGrouping)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var list = views
|
var list = views
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public static IUserManager UserManager { get; set; }
|
public static IUserManager UserManager { get; set; }
|
||||||
public static IXmlSerializer XmlSerializer { get; set; }
|
public static IXmlSerializer XmlSerializer { get; set; }
|
||||||
public bool EnableUserViews { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// From now on all user paths will be Id-based.
|
/// From now on all user paths will be Id-based.
|
||||||
|
|
|
@ -101,30 +101,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return GetChildren(user, false);
|
return GetChildren(user, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsExcludedFromGrouping(Folder folder)
|
|
||||||
{
|
|
||||||
var standaloneTypes = new List<string>
|
|
||||||
{
|
|
||||||
CollectionType.Books,
|
|
||||||
CollectionType.HomeVideos,
|
|
||||||
CollectionType.Photos,
|
|
||||||
CollectionType.Playlists,
|
|
||||||
CollectionType.BoxSets,
|
|
||||||
CollectionType.MusicVideos,
|
|
||||||
CollectionType.Games,
|
|
||||||
CollectionType.Music
|
|
||||||
};
|
|
||||||
|
|
||||||
var collectionFolder = folder as ICollectionFolder;
|
|
||||||
|
|
||||||
if (collectionFolder == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsUserSpecific(Folder folder)
|
public static bool IsUserSpecific(Folder folder)
|
||||||
{
|
{
|
||||||
var standaloneTypes = new List<string>
|
var standaloneTypes = new List<string>
|
||||||
|
@ -148,6 +124,24 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
|
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsEligibleForGrouping(Folder folder)
|
||||||
|
{
|
||||||
|
var collectionFolder = folder as ICollectionFolder;
|
||||||
|
return collectionFolder != null && IsEligibleForGrouping(collectionFolder.CollectionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsEligibleForGrouping(string viewType)
|
||||||
|
{
|
||||||
|
var types = new[]
|
||||||
|
{
|
||||||
|
CollectionType.Movies,
|
||||||
|
CollectionType.TvShows,
|
||||||
|
string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsEligibleForEnhancedView(string viewType)
|
public static bool IsEligibleForEnhancedView(string viewType)
|
||||||
{
|
{
|
||||||
var types = new[]
|
var types = new[]
|
||||||
|
|
|
@ -1712,12 +1712,12 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return _libraryManager.RootFolder
|
return _libraryManager.RootFolder
|
||||||
.Children
|
.Children
|
||||||
.OfType<Folder>()
|
.OfType<Folder>()
|
||||||
.Where(i => !UserView.IsExcludedFromGrouping(i));
|
.Where(UserView.IsEligibleForGrouping);
|
||||||
}
|
}
|
||||||
return user.RootFolder
|
return user.RootFolder
|
||||||
.GetChildren(user, true)
|
.GetChildren(user, true)
|
||||||
.OfType<Folder>()
|
.OfType<Folder>()
|
||||||
.Where(i => user.IsFolderGrouped(i.Id) && !UserView.IsExcludedFromGrouping(i));
|
.Where(i => user.IsFolderGrouped(i.Id) && UserView.IsEligibleForGrouping(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Folder> GetMediaFolders(User user, IEnumerable<string> viewTypes)
|
private IEnumerable<Folder> GetMediaFolders(User user, IEnumerable<string> viewTypes)
|
||||||
|
|
|
@ -337,7 +337,6 @@ namespace MediaBrowser.Controller.Library
|
||||||
string parentId,
|
string parentId,
|
||||||
string viewType,
|
string viewType,
|
||||||
string sortName,
|
string sortName,
|
||||||
string uniqueId,
|
|
||||||
CancellationToken cancellationToken);
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -391,13 +390,11 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <param name="parent">The parent.</param>
|
/// <param name="parent">The parent.</param>
|
||||||
/// <param name="viewType">Type of the view.</param>
|
/// <param name="viewType">Type of the view.</param>
|
||||||
/// <param name="sortName">Name of the sort.</param>
|
/// <param name="sortName">Name of the sort.</param>
|
||||||
/// <param name="uniqueId">The unique identifier.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task<UserView>.</returns>
|
/// <returns>Task<UserView>.</returns>
|
||||||
Task<UserView> GetShadowView(BaseItem parent,
|
Task<UserView> GetShadowView(BaseItem parent,
|
||||||
string viewType,
|
string viewType,
|
||||||
string sortName,
|
string sortName,
|
||||||
string uniqueId,
|
|
||||||
CancellationToken cancellationToken);
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -98,12 +98,6 @@ namespace MediaBrowser.Model.Configuration
|
||||||
/// <value><c>true</c> if [enable localized guids]; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if [enable localized guids]; otherwise, <c>false</c>.</value>
|
||||||
public bool EnableLocalizedGuids { get; set; }
|
public bool EnableLocalizedGuids { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether [enable user views].
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>true</c> if [enable user views]; otherwise, <c>false</c>.</value>
|
|
||||||
public bool EnableUserViews { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether [enable library metadata sub folder].
|
/// Gets or sets a value indicating whether [enable library metadata sub folder].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -229,7 +223,6 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
public int MigrationVersion { get; set; }
|
public int MigrationVersion { get; set; }
|
||||||
public bool EnableImagePreDownloading { get; set; }
|
public bool EnableImagePreDownloading { get; set; }
|
||||||
public bool EnableSharedCollectionViewImage { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
|
|
|
@ -1320,7 +1320,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
|
var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
|
||||||
|
|
||||||
query.TopParentIds = parents.SelectMany(GetTopParentsForQuery).Select(i => i.Id.ToString("N")).ToArray();
|
SetTopParentIdsOrAncestors(query, parents);
|
||||||
|
|
||||||
return GetItemIds(query).Select(GetItemById);
|
return GetItemIds(query).Select(GetItemById);
|
||||||
}
|
}
|
||||||
|
@ -1329,11 +1329,35 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
|
var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
|
||||||
|
|
||||||
query.TopParentIds = parents.SelectMany(GetTopParentsForQuery).Select(i => i.Id.ToString("N")).ToArray();
|
SetTopParentIdsOrAncestors(query, parents);
|
||||||
|
|
||||||
return GetItems(query);
|
return GetItems(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetTopParentIdsOrAncestors(InternalItemsQuery query, List<BaseItem> parents)
|
||||||
|
{
|
||||||
|
if (parents.All(i =>
|
||||||
|
{
|
||||||
|
if ((i is ICollectionFolder) || (i is UserView))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Debug("Query requires ancestor query due to type: " + i.GetType().Name);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
// Optimize by querying against top level views
|
||||||
|
query.TopParentIds = parents.SelectMany(i => GetTopParentsForQuery(i, query.User)).Select(i => i.Id.ToString("N")).ToArray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We need to be able to query from any arbitrary ancestor up the tree
|
||||||
|
query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).Select(i => i.ToString("N")).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void AddUserToQuery(InternalItemsQuery query, User user)
|
private void AddUserToQuery(InternalItemsQuery query, User user)
|
||||||
{
|
{
|
||||||
if (query.AncestorIds.Length == 0 && !query.ParentId.HasValue && query.ChannelIds.Length == 0 && query.TopParentIds.Length == 0)
|
if (query.AncestorIds.Length == 0 && !query.ParentId.HasValue && query.ChannelIds.Length == 0 && query.TopParentIds.Length == 0)
|
||||||
|
@ -1345,11 +1369,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
}, CancellationToken.None).Result.ToList();
|
}, CancellationToken.None).Result.ToList();
|
||||||
|
|
||||||
query.TopParentIds = userViews.SelectMany(GetTopParentsForQuery).Select(i => i.Id.ToString("N")).ToArray();
|
query.TopParentIds = userViews.SelectMany(i => GetTopParentsForQuery(i, user)).Select(i => i.Id.ToString("N")).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<BaseItem> GetTopParentsForQuery(BaseItem item)
|
private IEnumerable<BaseItem> GetTopParentsForQuery(BaseItem item, User user)
|
||||||
{
|
{
|
||||||
var view = item as UserView;
|
var view = item as UserView;
|
||||||
|
|
||||||
|
@ -1371,7 +1395,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
var displayParent = GetItemById(view.DisplayParentId);
|
var displayParent = GetItemById(view.DisplayParentId);
|
||||||
if (displayParent != null)
|
if (displayParent != null)
|
||||||
{
|
{
|
||||||
return GetTopParentsForQuery(displayParent);
|
return GetTopParentsForQuery(displayParent, user);
|
||||||
}
|
}
|
||||||
return new BaseItem[] { };
|
return new BaseItem[] { };
|
||||||
}
|
}
|
||||||
|
@ -1380,12 +1404,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
var displayParent = GetItemById(view.ParentId);
|
var displayParent = GetItemById(view.ParentId);
|
||||||
if (displayParent != null)
|
if (displayParent != null)
|
||||||
{
|
{
|
||||||
return GetTopParentsForQuery(displayParent);
|
return GetTopParentsForQuery(displayParent, user);
|
||||||
}
|
}
|
||||||
return new BaseItem[] { };
|
return new BaseItem[] { };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle grouping
|
// Handle grouping
|
||||||
|
if (user != null && !string.IsNullOrWhiteSpace(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType))
|
||||||
|
{
|
||||||
|
var collectionFolders = user.RootFolder.GetChildren(user, true).OfType<CollectionFolder>().Where(i => string.IsNullOrWhiteSpace(i.CollectionType) || string.Equals(i.CollectionType, view.ViewType, StringComparison.OrdinalIgnoreCase));
|
||||||
|
return collectionFolders.SelectMany(i => GetTopParentsForQuery(i, user));
|
||||||
|
}
|
||||||
return new BaseItem[] { };
|
return new BaseItem[] { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1797,7 +1826,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
string sortName,
|
string sortName,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return GetNamedViewInternal(user, name, null, viewType, sortName, null, cancellationToken);
|
return GetNamedView(user, name, null, viewType, sortName, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<UserView> GetNamedView(string name,
|
public async Task<UserView> GetNamedView(string name,
|
||||||
|
@ -1815,8 +1844,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
var refresh = false;
|
var refresh = false;
|
||||||
|
|
||||||
if (item == null ||
|
if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
|
||||||
!string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
_fileSystem.CreateDirectory(path);
|
_fileSystem.CreateDirectory(path);
|
||||||
|
|
||||||
|
@ -1835,11 +1863,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.Equals(viewType, item.ViewType, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
refresh = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!refresh)
|
if (!refresh)
|
||||||
{
|
{
|
||||||
refresh = (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
refresh = (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
||||||
|
@ -1865,40 +1888,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<UserView> GetNamedView(User user,
|
public async Task<UserView> GetNamedView(User user,
|
||||||
string name,
|
string name,
|
||||||
string parentId,
|
string parentId,
|
||||||
string viewType,
|
string viewType,
|
||||||
string sortName,
|
string sortName,
|
||||||
string uniqueId,
|
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(parentId))
|
var idValues = "38_namedview_" + name + user.Id.ToString("N") + (parentId ?? string.Empty) + (viewType ?? string.Empty);
|
||||||
{
|
|
||||||
throw new ArgumentNullException("parentId");
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetNamedViewInternal(user, name, parentId, viewType, sortName, uniqueId, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<UserView> GetNamedViewInternal(User user,
|
|
||||||
string name,
|
|
||||||
string parentId,
|
|
||||||
string viewType,
|
|
||||||
string sortName,
|
|
||||||
string uniqueId,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("name");
|
|
||||||
}
|
|
||||||
|
|
||||||
var idValues = "37_namedview_" + name + user.Id.ToString("N") + (parentId ?? string.Empty);
|
|
||||||
if (!string.IsNullOrWhiteSpace(uniqueId))
|
|
||||||
{
|
|
||||||
idValues += uniqueId;
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = GetNewItemId(idValues, typeof(UserView));
|
var id = GetNewItemId(idValues, typeof(UserView));
|
||||||
|
|
||||||
|
@ -1933,13 +1930,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
isNew = true;
|
isNew = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.UserId.HasValue || !string.Equals(viewType, item.ViewType, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
item.UserId = user.Id;
|
|
||||||
item.ViewType = viewType;
|
|
||||||
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var refresh = isNew || (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
var refresh = isNew || (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
||||||
|
|
||||||
if (!refresh && item.DisplayParentId != Guid.Empty)
|
if (!refresh && item.DisplayParentId != Guid.Empty)
|
||||||
|
@ -1963,7 +1953,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
public async Task<UserView> GetShadowView(BaseItem parent,
|
public async Task<UserView> GetShadowView(BaseItem parent,
|
||||||
string viewType,
|
string viewType,
|
||||||
string sortName,
|
string sortName,
|
||||||
string uniqueId,
|
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
|
@ -1974,11 +1963,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
var name = parent.Name;
|
var name = parent.Name;
|
||||||
var parentId = parent.Id;
|
var parentId = parent.Id;
|
||||||
|
|
||||||
var idValues = "37_namedview_" + name + parentId + (viewType ?? string.Empty);
|
var idValues = "38_namedview_" + name + parentId + (viewType ?? string.Empty);
|
||||||
if (!string.IsNullOrWhiteSpace(uniqueId))
|
|
||||||
{
|
|
||||||
idValues += uniqueId;
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = GetNewItemId(idValues, typeof(UserView));
|
var id = GetNewItemId(idValues, typeof(UserView));
|
||||||
|
|
||||||
|
@ -2009,12 +1994,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
isNew = true;
|
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.DateLastRefreshed) >= _viewRefreshInterval;
|
var refresh = isNew || (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
||||||
|
|
||||||
if (!refresh && item.DisplayParentId != Guid.Empty)
|
if (!refresh && item.DisplayParentId != Guid.Empty)
|
||||||
|
|
|
@ -707,8 +707,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
DateCreated = DateTime.UtcNow,
|
DateCreated = DateTime.UtcNow,
|
||||||
DateModified = DateTime.UtcNow,
|
DateModified = DateTime.UtcNow,
|
||||||
UsesIdForConfigurationPath = true,
|
UsesIdForConfigurationPath = true
|
||||||
EnableUserViews = true
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,93 +60,52 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
var plainFolderIds = user.Configuration.PlainFolderViews.Select(i => new Guid(i)).ToList();
|
var plainFolderIds = user.Configuration.PlainFolderViews.Select(i => new Guid(i)).ToList();
|
||||||
|
|
||||||
var standaloneFolders = folders
|
var groupedFolders = new List<ICollectionFolder>();
|
||||||
.Where(i => UserView.IsExcludedFromGrouping(i) || !user.IsFolderGrouped(i.Id))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var foldersWithViewTypes = folders
|
|
||||||
.Except(standaloneFolders)
|
|
||||||
.OfType<ICollectionFolder>()
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var list = new List<Folder>();
|
var list = new List<Folder>();
|
||||||
|
|
||||||
var enableUserViews = _config.Configuration.EnableUserViews || user.EnableUserViews;
|
foreach (var folder in folders)
|
||||||
|
|
||||||
foreach (var folder in standaloneFolders)
|
|
||||||
{
|
{
|
||||||
var collectionFolder = folder as ICollectionFolder;
|
var collectionFolder = folder as ICollectionFolder;
|
||||||
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
|
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
|
||||||
|
|
||||||
if (UserView.IsUserSpecific(folder))
|
if (UserView.IsUserSpecific(folder))
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
list.Add(await _libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken).ConfigureAwait(false));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableUserViews)
|
|
||||||
{
|
|
||||||
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
|
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
|
||||||
{
|
|
||||||
list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false));
|
|
||||||
}
|
|
||||||
else if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
|
|
||||||
}
|
|
||||||
else if (_config.Configuration.EnableSharedCollectionViewImage || UserView.EnableOriginalFolder(folderViewType))
|
|
||||||
{
|
{
|
||||||
list.Add(folder);
|
list.Add(folder);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrWhiteSpace(folderViewType))
|
|
||||||
|
if (collectionFolder != null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id))
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
|
groupedFolders.Add(collectionFolder);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
list.Add(await GetUserView(folder, folderViewType, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list.Add(folder);
|
list.Add(folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: Deprecate this whole block
|
|
||||||
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
|
|
||||||
{
|
|
||||||
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
|
||||||
}
|
|
||||||
else if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
|
|
||||||
}
|
|
||||||
else if (_config.Configuration.EnableSharedCollectionViewImage || UserView.EnableOriginalFolder(folderViewType))
|
|
||||||
{
|
|
||||||
list.Add(folder);
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrWhiteSpace(folderViewType))
|
|
||||||
{
|
|
||||||
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list.Add(folder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
|
foreach (var viewType in new[] { CollectionType.Movies, CollectionType.TvShows })
|
||||||
|
{
|
||||||
|
var parents = groupedFolders.Where(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (parents.Count > 0)
|
if (parents.Count > 0)
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(parents, CollectionType.TvShows, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false));
|
list.Add(await GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (parents.Count > 0)
|
|
||||||
{
|
|
||||||
list.Add(await GetUserView(parents, CollectionType.Movies, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Configuration.DisplayFoldersView)
|
if (user.Configuration.DisplayFoldersView)
|
||||||
|
@ -225,35 +184,23 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken)
|
private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (parents.Count == 1 && parents.All(i => string.Equals(i.GetViewType(user), viewType, StringComparison.OrdinalIgnoreCase)))
|
if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
if (!presetViews.Contains(viewType, StringComparer.OrdinalIgnoreCase))
|
if (!presetViews.Contains(viewType, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return (Folder)parents[0];
|
return (Folder)parents[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
var parentId = parents[0].Id;
|
return await GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
return await GetUserView((Folder)parents[0], viewType, enableRichView, string.Empty, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = _localizationManager.GetLocalizedString("ViewType" + viewType);
|
var name = _localizationManager.GetLocalizedString("ViewType" + viewType);
|
||||||
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
|
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<UserView> GetUserView(Guid parentId, string name, string viewType, bool enableRichView, string sortName, User user, CancellationToken cancellationToken)
|
public Task<UserView> GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
viewType = enableRichView ? viewType : null;
|
return _libraryManager.GetShadowView(parent, viewType, sortName, cancellationToken);
|
||||||
return _libraryManager.GetNamedView(user, name, parentId.ToString("N"), viewType, sortName, null, cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<UserView> GetUserView(Folder parent, string viewType, bool enableRichView, string sortName, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
viewType = enableRichView ? viewType : null;
|
|
||||||
|
|
||||||
return _libraryManager.GetShadowView(parent, viewType, sortName, null, cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request)
|
public List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request)
|
||||||
|
|
|
@ -2296,7 +2296,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||||
public async Task<Folder> GetInternalLiveTvFolder(CancellationToken cancellationToken)
|
public async Task<Folder> GetInternalLiveTvFolder(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var name = _localization.GetLocalizedString("ViewTypeLiveTV");
|
var name = _localization.GetLocalizedString("ViewTypeLiveTV");
|
||||||
return await _libraryManager.GetNamedView(name, "livetv", name, cancellationToken).ConfigureAwait(false);
|
return await _libraryManager.GetNamedView(name, CollectionType.LiveTv, name, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info)
|
public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info)
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
public const int MigrationVersion = 6;
|
public const int MigrationVersion = 7;
|
||||||
|
|
||||||
public CleanDatabaseScheduledTask(ILibraryManager libraryManager, IItemRepository itemRepo, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem)
|
public CleanDatabaseScheduledTask(ILibraryManager libraryManager, IItemRepository itemRepo, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
|
@ -75,10 +75,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
{
|
{
|
||||||
var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
IsCurrentSchema = false,
|
IsCurrentSchema = false
|
||||||
|
|
||||||
// These are constantly getting regenerated so don't bother with them here
|
|
||||||
ExcludeItemTypes = new[] { typeof(LiveTvProgram).Name }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var numComplete = 0;
|
var numComplete = 0;
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
|
|
||||||
private IDbCommand _updateInheritedRatingCommand;
|
private IDbCommand _updateInheritedRatingCommand;
|
||||||
|
|
||||||
private const int LatestSchemaVersion = 37;
|
private const int LatestSchemaVersion = 40;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace MediaBrowser.ServerApplication
|
||||||
if (!duplicate.WaitForExit(10000))
|
if (!duplicate.WaitForExit(10000))
|
||||||
{
|
{
|
||||||
_logger.Info("The duplicate process did not exit.");
|
_logger.Info("The duplicate process did not exit.");
|
||||||
return true;
|
//return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user