support custom ordering of user views

This commit is contained in:
Luke Pulverenti
2014-08-18 21:42:53 -04:00
parent 6a2f6782d3
commit b48d15296c
14 changed files with 195 additions and 78 deletions

View File

@@ -133,7 +133,19 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
return _libraryManager.Sort(list, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).Cast<Folder>();
var sorted = _libraryManager.Sort(list, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList();
var orders = user.Configuration.OrderedViews.ToList();
return list
.OrderBy(i =>
{
var index = orders.IndexOf(i.Id.ToString("N"));
return index == -1 ? int.MaxValue : index;
})
.ThenBy(sorted.IndexOf)
.ThenBy(i => i.SortName);
}
public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)