Skip to content

Commit

Permalink
Added WishlistOnly filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Feb 25, 2024
1 parent 39eb291 commit 3819e5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions FreePackages/Data/FilterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ internal sealed class FilterConfig {
[JsonProperty(Required = Required.Default)]
internal HashSet<string> Systems = new();

[JsonProperty(Required = Required.Default)]
internal bool WishlistOnly = false;

[JsonConstructor]
internal FilterConfig() { }
}
Expand Down
6 changes: 6 additions & 0 deletions FreePackages/Data/UserData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ internal sealed class UserData {
[JsonProperty(PropertyName = "rgExcludedContentDescriptorIDs", Required = Required.Always)]
internal HashSet<uint> ExcludedContentDescriptorIDs = new();

[JsonProperty(PropertyName = "rgWishlist", Required = Required.Always)]
internal HashSet<uint> WishlistedApps = new();

[JsonProperty(PropertyName = "rgFollowedApps", Required = Required.Always)]
internal HashSet<uint> FollowedApps = new();

[JsonExtensionData]
internal Dictionary<string, JToken> AdditionalData = new();

Expand Down
9 changes: 9 additions & 0 deletions FreePackages/Handlers/PackageFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ internal bool IsRedeemableApp(FilterableApp app, HashSet<uint>? includedAppIDs =
}

internal bool IsAppWantedByFilter(FilterableApp app, FilterConfig filter) {
if (UserData == null) {
throw new InvalidOperationException(nameof(UserData));
}

if (filter.Types.Count > 0 && app.Type != EAppType.Beta && !app.HasType(filter.Types)) {
// Don't require user to specify they want playtests (Beta), this is already implied by the PlaytestMode filter
// App isn't a wanted type
Expand Down Expand Up @@ -115,6 +119,11 @@ internal bool IsAppWantedByFilter(FilterableApp app, FilterConfig filter) {
return false;
}

if (filter.WishlistOnly && !UserData.WishlistedApps.Contains(app.ID) && !UserData.FollowedApps.Contains(app.ID)) {
// Unwated to due not being wishlisted or followed on the Steam storefront
return false;
}

return true;
}

Expand Down

0 comments on commit 3819e5f

Please sign in to comment.