diff --git a/Shoko.Server/Filters/FilterExtensions.cs b/Shoko.Server/Filters/FilterExtensions.cs index e5b8bb21b..c2e5e76ed 100644 --- a/Shoko.Server/Filters/FilterExtensions.cs +++ b/Shoko.Server/Filters/FilterExtensions.cs @@ -92,6 +92,9 @@ public static Filterable ToFilterable(this SVR_AnimeSeries series, ILookup a.Intersect(b, StringComparer.InvariantCultureIgnoreCase)).ToHashSet(); return subtitles; }, + ResolutionsDelegate = () => + series.GetVideoLocals().Select(a => MediaInfoUtils.GetStandardResolution(Tuple.Create(a.Media.VideoStream.Width, a.Media.VideoStream.Height))) + .ToHashSet() }; return filterable; diff --git a/Shoko.Server/Filters/FilterableUserInfo.cs b/Shoko.Server/Filters/FilterableUserInfo.cs index 5b5b21af3..e354de87d 100644 --- a/Shoko.Server/Filters/FilterableUserInfo.cs +++ b/Shoko.Server/Filters/FilterableUserInfo.cs @@ -7,142 +7,83 @@ namespace Shoko.Server.Filters; public class FilterableUserInfo : IFilterableUserInfo { private readonly Lazy _hasPermanentVotes; - private readonly Func _hasPermanentVotesDelegate; - private readonly Lazy _hasVotes; - private readonly Func _hasVotesDelegate; - private readonly Lazy _highestUserRating; - private readonly Func _highestUserRatingDelegate; - private readonly Lazy _isFavorite; - private readonly Func _isFavoriteDelegate; - private readonly Lazy _lastWatchedDate; - private readonly Func _lastWatchedDateDelegate; - private readonly Lazy _lowestUserRating; - private readonly Func _lowestUserRatingDelegate; - private readonly Lazy _missingPermanentVotes; - private readonly Func _missingPermanentVotesDelegate; - private readonly Lazy _unwatchedEpisodes; - private readonly Func _unwatchedEpisodesDelegate; - private readonly Lazy _watchedDate; - private readonly Func _watchedDateDelegate; - private readonly Lazy _watchedEpisodes; - private readonly Func _watchedEpisodesDelegate; public bool IsFavorite => _isFavorite.Value; public Func IsFavoriteDelegate { - init - { - _isFavoriteDelegate = value; - _isFavorite = new Lazy(_isFavoriteDelegate, LazyThreadSafetyMode.None); - } + init => _isFavorite = new Lazy(value); } public int WatchedEpisodes => _watchedEpisodes.Value; public Func WatchedEpisodesDelegate { - init - { - _watchedEpisodesDelegate = value; - _watchedEpisodes = new Lazy(_watchedEpisodesDelegate, LazyThreadSafetyMode.None); - } + init => _watchedEpisodes = new Lazy(value); } public int UnwatchedEpisodes => _unwatchedEpisodes.Value; public Func UnwatchedEpisodesDelegate { - init - { - _unwatchedEpisodesDelegate = value; - _unwatchedEpisodes = new Lazy(_unwatchedEpisodesDelegate, LazyThreadSafetyMode.None); - } + init => _unwatchedEpisodes = new Lazy(value); } public bool HasVotes => _hasVotes.Value; public Func HasVotesDelegate { - init - { - _hasVotesDelegate = value; - _hasVotes = new Lazy(_hasVotesDelegate, LazyThreadSafetyMode.None); - } + init => _hasVotes = new Lazy(value); } public bool HasPermanentVotes => _hasPermanentVotes.Value; public Func HasPermanentVotesDelegate { - init - { - _hasPermanentVotesDelegate = value; - _hasPermanentVotes = new Lazy(_hasPermanentVotesDelegate, LazyThreadSafetyMode.None); - } + init => _hasPermanentVotes = new Lazy(value); } public bool MissingPermanentVotes => _missingPermanentVotes.Value; public Func MissingPermanentVotesDelegate { - init - { - _missingPermanentVotesDelegate = value; - _missingPermanentVotes = new Lazy(_missingPermanentVotesDelegate, LazyThreadSafetyMode.None); - } + init => _missingPermanentVotes = new Lazy(value); } public DateTime? WatchedDate => _watchedDate.Value; public Func WatchedDateDelegate { - init - { - _watchedDateDelegate = value; - _watchedDate = new Lazy(_watchedDateDelegate, LazyThreadSafetyMode.None); - } + init => _watchedDate = new Lazy(value); } public DateTime? LastWatchedDate => _lastWatchedDate.Value; public Func LastWatchedDateDelegate { - init - { - _lastWatchedDateDelegate = value; - _lastWatchedDate = new Lazy(_lastWatchedDateDelegate, LazyThreadSafetyMode.None); - } + init => _lastWatchedDate = new Lazy(value); } public decimal LowestUserRating => _lowestUserRating.Value; public Func LowestUserRatingDelegate { - init - { - _lowestUserRatingDelegate = value; - _lowestUserRating = new Lazy(_lowestUserRatingDelegate, LazyThreadSafetyMode.None); - } + init => _lowestUserRating = new Lazy(value); } public decimal HighestUserRating => _highestUserRating.Value; public Func HighestUserRatingDelegate { - init - { - _highestUserRatingDelegate = value; - _highestUserRating = new Lazy(_highestUserRatingDelegate, LazyThreadSafetyMode.None); - } + init => _highestUserRating = new Lazy(value); } }