private async Task<QueryResult<BaseItem>> GetUserItems(Folder folder, User user, SortCriteria sort, int? startIndex, int? limit) { var sortOrders = new List<string>(); if (!folder.IsPreSorted) { sortOrders.Add(ItemSortBy.SortName); } return await folder.GetUserItems(new UserItemsQuery { Limit = limit, StartIndex = startIndex, SortBy = sortOrders.ToArray(), SortOrder = sort.SortOrder, User = user, Filter = FilterUnsupportedContent }).ConfigureAwait(false); }
private async Task<QueryResult<BaseItem>> GetChildrenSorted(Folder folder, User user, SearchCriteria search, SortCriteria sort, int? startIndex, int? limit) { var sortOrders = new List<string>(); if (!folder.IsPreSorted) { sortOrders.Add(ItemSortBy.SortName); } var mediaTypes = new List<string>(); bool? isFolder = null; if (search.SearchType == SearchType.Audio) { mediaTypes.Add(MediaType.Audio); isFolder = false; } else if (search.SearchType == SearchType.Video) { mediaTypes.Add(MediaType.Video); isFolder = false; } else if (search.SearchType == SearchType.Image) { mediaTypes.Add(MediaType.Photo); isFolder = false; } else if (search.SearchType == SearchType.Playlist) { //items = items.OfType<Playlist>(); isFolder = true; } else if (search.SearchType == SearchType.MusicAlbum) { //items = items.OfType<MusicAlbum>(); isFolder = true; } return await folder.GetUserItems(new UserItemsQuery { Limit = limit, StartIndex = startIndex, SortBy = sortOrders.ToArray(), SortOrder = sort.SortOrder, User = user, Recursive = true, Filter = FilterUnsupportedContent, IsFolder = isFolder, MediaTypes = mediaTypes.ToArray() }).ConfigureAwait(false); }