Skip to content

Commit

Permalink
Merge pull request jellyfin#6074 from Bond-009/nullablequery
Browse files Browse the repository at this point in the history
Enable nullable for InternalItemsQuery
  • Loading branch information
Bond-009 authored May 18, 2021
2 parents 44087da + 2b321d8 commit 19e9bef
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 46 deletions.
4 changes: 2 additions & 2 deletions Emby.Server.Implementations/Data/SqliteItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,7 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem
whereClauses.Add(string.Join(" AND ", excludeIds));
}

if (query.ExcludeProviderIds.Count > 0)
if (query.ExcludeProviderIds != null && query.ExcludeProviderIds.Count > 0)
{
var excludeIds = new List<string>();

Expand Down Expand Up @@ -4457,7 +4457,7 @@ private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statem
}
}

if (query.HasAnyProviderId.Count > 0)
if (query.HasAnyProviderId != null && query.HasAnyProviderId.Count > 0)
{
var hasProviderIds = new List<string>();

Expand Down
85 changes: 41 additions & 44 deletions MediaBrowser.Controller/Entities/InternalItemsQuery.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#nullable disable

#pragma warning disable CS1591

using System;
Expand All @@ -20,9 +18,9 @@ public class InternalItemsQuery

public int? Limit { get; set; }

public User User { get; set; }
public User? User { get; set; }

public BaseItem SimilarTo { get; set; }
public BaseItem? SimilarTo { get; set; }

public bool? IsFolder { get; set; }

Expand Down Expand Up @@ -58,31 +56,31 @@ public class InternalItemsQuery

public bool? CollapseBoxSetItems { get; set; }

public string NameStartsWithOrGreater { get; set; }
public string? NameStartsWithOrGreater { get; set; }

public string NameStartsWith { get; set; }
public string? NameStartsWith { get; set; }

public string NameLessThan { get; set; }
public string? NameLessThan { get; set; }

public string NameContains { get; set; }
public string? NameContains { get; set; }

public string MinSortName { get; set; }
public string? MinSortName { get; set; }

public string PresentationUniqueKey { get; set; }
public string? PresentationUniqueKey { get; set; }

public string Path { get; set; }
public string? Path { get; set; }

public string Name { get; set; }
public string? Name { get; set; }

public string Person { get; set; }
public string? Person { get; set; }

public Guid[] PersonIds { get; set; }

public Guid[] ItemIds { get; set; }

public Guid[] ExcludeItemIds { get; set; }

public string AdjacentTo { get; set; }
public string? AdjacentTo { get; set; }

public string[] PersonTypes { get; set; }

Expand Down Expand Up @@ -182,13 +180,13 @@ public class InternalItemsQuery

public Guid ParentId { get; set; }

public string ParentType { get; set; }
public string? ParentType { get; set; }

public Guid[] AncestorIds { get; set; }

public Guid[] TopParentIds { get; set; }

public BaseItem Parent
public BaseItem? Parent
{
set
{
Expand All @@ -213,19 +211,19 @@ public BaseItem Parent

public SeriesStatus[] SeriesStatuses { get; set; }

public string ExternalSeriesId { get; set; }
public string? ExternalSeriesId { get; set; }

public string ExternalId { get; set; }
public string? ExternalId { get; set; }

public Guid[] AlbumIds { get; set; }

public Guid[] ArtistIds { get; set; }

public Guid[] ExcludeArtistIds { get; set; }

public string AncestorWithPresentationUniqueKey { get; set; }
public string? AncestorWithPresentationUniqueKey { get; set; }

public string SeriesPresentationUniqueKey { get; set; }
public string? SeriesPresentationUniqueKey { get; set; }

public bool GroupByPresentationUniqueKey { get; set; }

Expand All @@ -235,7 +233,7 @@ public BaseItem Parent

public bool ForceDirect { get; set; }

public Dictionary<string, string> ExcludeProviderIds { get; set; }
public Dictionary<string, string>? ExcludeProviderIds { get; set; }

public bool EnableGroupByMetadataKey { get; set; }

Expand All @@ -253,13 +251,13 @@ public BaseItem Parent

public int MinSimilarityScore { get; set; }

public string HasNoAudioTrackWithLanguage { get; set; }
public string? HasNoAudioTrackWithLanguage { get; set; }

public string HasNoInternalSubtitleTrackWithLanguage { get; set; }
public string? HasNoInternalSubtitleTrackWithLanguage { get; set; }

public string HasNoExternalSubtitleTrackWithLanguage { get; set; }
public string? HasNoExternalSubtitleTrackWithLanguage { get; set; }

public string HasNoSubtitleTrackWithLanguage { get; set; }
public string? HasNoSubtitleTrackWithLanguage { get; set; }

public bool? IsDeadArtist { get; set; }

Expand All @@ -283,12 +281,10 @@ public InternalItemsQuery()
ExcludeInheritedTags = Array.Empty<string>();
ExcludeItemIds = Array.Empty<Guid>();
ExcludeItemTypes = Array.Empty<string>();
ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
ExcludeTags = Array.Empty<string>();
GenreIds = Array.Empty<Guid>();
Genres = Array.Empty<string>();
GroupByPresentationUniqueKey = true;
HasAnyProviderId = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
ImageTypes = Array.Empty<ImageType>();
IncludeItemTypes = Array.Empty<string>();
ItemIds = Array.Empty<Guid>();
Expand All @@ -309,32 +305,33 @@ public InternalItemsQuery()
Years = Array.Empty<int>();
}

public InternalItemsQuery(User user)
public InternalItemsQuery(User? user)
: this()
{
SetUser(user);
if (user != null)
{
SetUser(user);
}
}

public void SetUser(User user)
{
if (user != null)
{
MaxParentalRating = user.MaxParentalAgeRating;
MaxParentalRating = user.MaxParentalAgeRating;

if (MaxParentalRating.HasValue)
{
BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
.Where(i => i != UnratedItem.Other.ToString())
.Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
}
if (MaxParentalRating.HasValue)
{
string other = UnratedItem.Other.ToString();
BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems)
.Where(i => i != other)
.Select(e => Enum.Parse<UnratedItem>(e, true)).ToArray();
}

ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);

User = user;
}
User = user;
}

public Dictionary<string, string> HasAnyProviderId { get; set; }
public Dictionary<string, string>? HasAnyProviderId { get; set; }

public Guid[] AlbumArtistIds { get; set; }

Expand All @@ -356,8 +353,8 @@ public void SetUser(User user)

public int? MinWidth { get; set; }

public string SearchTerm { get; set; }
public string? SearchTerm { get; set; }

public string SeriesTimerId { get; set; }
public string? SeriesTimerId { get; set; }
}
}

0 comments on commit 19e9bef

Please sign in to comment.