diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 5fa96c34b7..2584fa4f0a 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1213,6 +1213,7 @@ namespace MediaBrowser.Server.Implementations.Dto var unplayed = 0; long runtime = 0; + DateTime? dateLastMediaAdded = null; double totalPercentPlayed = 0; IEnumerable children; @@ -1231,6 +1232,15 @@ namespace MediaBrowser.Server.Implementations.Dto // Loop through each recursive child foreach (var child in children) { + if (!dateLastMediaAdded.HasValue) + { + dateLastMediaAdded = child.DateCreated; + } + else + { + dateLastMediaAdded = new[] { dateLastMediaAdded.Value, child.DateCreated }.Max(); + } + var userdata = _userDataRepository.GetUserData(user.Id, child.GetUserDataKey()); recursiveItemCount++; @@ -1281,6 +1291,11 @@ namespace MediaBrowser.Server.Implementations.Dto { dto.CumulativeRunTimeTicks = runtime; } + + if (fields.Contains(ItemFields.DateLastMediaAdded)) + { + dto.DateLastMediaAdded = dateLastMediaAdded; + } } ///