Filter full device list only once

Signed-off-by: gnattu <gnattuoc@me.com>
This commit is contained in:
gnattu 2024-06-29 14:11:28 +08:00
parent dd5f6406a2
commit c05049e54e

View File

@ -137,10 +137,11 @@ namespace Jellyfin.Server.Implementations.Devices
/// <inheritdoc />
public QueryResult<Device> GetDevices(DeviceQuery query)
{
var devices = _devices.Values.OrderBy(d => d.Id)
IEnumerable<Device> devices = _devices.Values.OrderBy(d => d.Id)
.Where(device => !query.UserId.HasValue || device.UserId.Equals(query.UserId.Value))
.Where(device => query.DeviceId == null || device.DeviceId == query.DeviceId)
.Where(device => query.AccessToken == null || device.AccessToken == query.AccessToken);
.Where(device => query.AccessToken == null || device.AccessToken == query.AccessToken)
.ToList();
var count = devices.Count();
if (query.Skip.HasValue)