|
@@ -119,12 +119,29 @@ namespace MediaBrowser.Server.Implementations.TV
|
|
// Avoid implicitly captured closure
|
|
// Avoid implicitly captured closure
|
|
var currentUser = user;
|
|
var currentUser = user;
|
|
|
|
|
|
- return series
|
|
|
|
|
|
+ var allNextUp = series
|
|
.Select(i => GetNextUp(i, currentUser))
|
|
.Select(i => GetNextUp(i, currentUser))
|
|
|
|
+ .Where(i => i.Item1 != null)
|
|
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
|
|
// Include if an episode was found, and either the series is not unwatched or the specific series was requested
|
|
- .Where(i => i.Item1 != null && (!i.Item3 || !string.IsNullOrWhiteSpace(request.SeriesId)))
|
|
|
|
.OrderByDescending(i => i.Item2)
|
|
.OrderByDescending(i => i.Item2)
|
|
.ThenByDescending(i => i.Item1.PremiereDate ?? DateTime.MinValue)
|
|
.ThenByDescending(i => i.Item1.PremiereDate ?? DateTime.MinValue)
|
|
|
|
+ .ToList();
|
|
|
|
+
|
|
|
|
+ // If viewing all next up for all series, remove first episodes
|
|
|
|
+ if (string.IsNullOrWhiteSpace(request.SeriesId))
|
|
|
|
+ {
|
|
|
|
+ var withoutFirstEpisode = allNextUp
|
|
|
|
+ .Where(i => !i.Item3)
|
|
|
|
+ .ToList();
|
|
|
|
+
|
|
|
|
+ // But if that returns empty, keep those first episodes (avoid completely empty view)
|
|
|
|
+ if (withoutFirstEpisode.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ allNextUp = withoutFirstEpisode;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return allNextUp
|
|
.Select(i => i.Item1)
|
|
.Select(i => i.Item1)
|
|
.Take(request.Limit ?? int.MaxValue);
|
|
.Take(request.Limit ?? int.MaxValue);
|
|
}
|
|
}
|