diff options
| author | crobibero <cody@robibe.ro> | 2020-11-09 14:57:02 -0700 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-11-09 14:57:02 -0700 |
| commit | 6748ba287d8cd9054072ce1ffc51c7aa8690e108 (patch) | |
| tree | 5b859fa356ef2f6abd5fb281ff5655ccf5fd3ebf /Emby.Server.Implementations/Channels | |
| parent | f8e6edbfeb8c437c2ed0a9c9b44bed0fc105b2c2 (diff) | |
| parent | 296e534f670df9069e8cb50683a964ea2a5cdc37 (diff) | |
Merge remote-tracking branch 'upstream/master' into query-fields
Diffstat (limited to 'Emby.Server.Implementations/Channels')
| -rw-r--r-- | Emby.Server.Implementations/Channels/ChannelManager.cs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index db44bf489..19045b72b 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -250,21 +250,16 @@ namespace Emby.Server.Implementations.Channels var all = channels; var totalCount = all.Count; - if (query.StartIndex.HasValue) + if (query.StartIndex.HasValue || query.Limit.HasValue) { - all = all.Skip(query.StartIndex.Value).ToList(); + int startIndex = query.StartIndex ?? 0; + int count = query.Limit == null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex); + all = all.GetRange(startIndex, count); } - if (query.Limit.HasValue) - { - all = all.Take(query.Limit.Value).ToList(); - } - - var returnItems = all.ToArray(); - if (query.RefreshLatestChannelItems) { - foreach (var item in returnItems) + foreach (var item in all) { RefreshLatestChannelItems(GetChannelProvider(item), CancellationToken.None).GetAwaiter().GetResult(); } @@ -272,7 +267,7 @@ namespace Emby.Server.Implementations.Channels return new QueryResult<Channel> { - Items = returnItems, + Items = all, TotalRecordCount = totalCount }; } |
