aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/InstantMixController.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2025-01-25 02:08:44 -0500
committerGitHub <noreply@github.com>2025-01-25 02:08:44 -0500
commit93b8eade617dbce16979bbada63b7faf44c5ce82 (patch)
tree5ef83a80b4ef1f713961d32ee6311c6033a3a9a9 /Jellyfin.Api/Controllers/InstantMixController.cs
parent679ee960d346f24d7df559cbbaf95cf1c9567345 (diff)
parent64cf67f1ac758acd36db61432c97e434d9f9225d (diff)
Merge pull request #12798 from JPVenson/feature/EFUserData
Refactor library.db into jellyfin.db and EFCore
Diffstat (limited to 'Jellyfin.Api/Controllers/InstantMixController.cs')
-rw-r--r--Jellyfin.Api/Controllers/InstantMixController.cs16
1 files changed, 7 insertions, 9 deletions
diff --git a/Jellyfin.Api/Controllers/InstantMixController.cs b/Jellyfin.Api/Controllers/InstantMixController.cs
index dcbacf1d7..87a856d38 100644
--- a/Jellyfin.Api/Controllers/InstantMixController.cs
+++ b/Jellyfin.Api/Controllers/InstantMixController.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
+using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
@@ -389,23 +391,19 @@ public class InstantMixController : BaseJellyfinApiController
return GetResult(items, user, limit, dtoOptions);
}
- private QueryResult<BaseItemDto> GetResult(List<BaseItem> items, User? user, int? limit, DtoOptions dtoOptions)
+ private QueryResult<BaseItemDto> GetResult(IReadOnlyList<BaseItem> items, User? user, int? limit, DtoOptions dtoOptions)
{
- var list = items;
+ var totalCount = items.Count;
- var totalCount = list.Count;
-
- if (limit.HasValue && limit < list.Count)
+ if (limit.HasValue && limit < items.Count)
{
- list = list.GetRange(0, limit.Value);
+ items = items.Take(limit.Value).ToArray();
}
- var returnList = _dtoService.GetBaseItemDtos(list, dtoOptions, user);
-
var result = new QueryResult<BaseItemDto>(
0,
totalCount,
- returnList);
+ _dtoService.GetBaseItemDtos(items, dtoOptions, user));
return result;
}