aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Dto/DtoService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Dto/DtoService.cs')
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs19
1 files changed, 10 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 5103b1fbf..45270de89 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -83,22 +83,23 @@ namespace Emby.Server.Implementations.Dto
/// <inheritdoc />
public IReadOnlyList<BaseItemDto> GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
{
- var returnItems = new BaseItemDto[items.Count];
- var programTuples = new List<(BaseItem, BaseItemDto)>();
- var channelTuples = new List<(BaseItemDto, LiveTvChannel)>();
+ var accessibleItems = user is null ? items : items.Where(x => x.IsVisible(user)).ToList();
+ var returnItems = new BaseItemDto[accessibleItems.Count];
+ List<(BaseItem, BaseItemDto)> programTuples = null;
+ List<(BaseItemDto, LiveTvChannel)> channelTuples = null;
- for (int index = 0; index < items.Count; index++)
+ for (int index = 0; index < accessibleItems.Count; index++)
{
- var item = items[index];
+ var item = accessibleItems[index];
var dto = GetBaseItemDtoInternal(item, options, user, owner);
if (item is LiveTvChannel tvChannel)
{
- channelTuples.Add((dto, tvChannel));
+ (channelTuples ??= new()).Add((dto, tvChannel));
}
else if (item is LiveTvProgram)
{
- programTuples.Add((item, dto));
+ (programTuples ??= new()).Add((item, dto));
}
if (item is IItemByName byName)
@@ -121,12 +122,12 @@ namespace Emby.Server.Implementations.Dto
returnItems[index] = dto;
}
- if (programTuples.Count > 0)
+ if (programTuples is not null)
{
LivetvManager.AddInfoToProgramDto(programTuples, options.Fields, user).GetAwaiter().GetResult();
}
- if (channelTuples.Count > 0)
+ if (channelTuples is not null)
{
LivetvManager.AddChannelInfo(channelTuples, options, user);
}