-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MBL-1316: Use isAvailable to filter visible add-ons #2012
Merged
+171
−37
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1367289
MBL-1316: Show add-ons for late pledges
amy-at-kickstarter 8007762
MBL-1316: Add isAvailable to Reward (available from GraphQL)
amy-at-kickstarter 589898b
MBL-1316: Use isAvailable to filter visible add-ons
amy-at-kickstarter 031c740
update ksApi tests
scottkicks 2cbc38f
Merge branch 'main' into feat/adyer/MBL-1316/fix-add-ons
scottkicks 7d07853
Fix RewardAddOnSelectionViewControllerTests
amy-at-kickstarter File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,6 @@ public final class RewardAddOnSelectionViewModel: RewardAddOnSelectionViewModelT | |
self.endRefreshing = projectEvent.filter { $0.isTerminating }.ignoreValues() | ||
|
||
let addOns = projectEvent.values().map(\.rewardData.addOns).skipNil() | ||
|
||
let requestErrored = projectEvent.map(\.error).map(isNotNil) | ||
|
||
// Quantities updated as the user selects them, merged with an empty initial value. | ||
|
@@ -468,17 +467,7 @@ private func addOnIsAvailable(_ addOn: Reward, in project: Project) -> Bool { | |
return true | ||
} | ||
|
||
let isUnlimitedOrAvailable = addOn.limit == nil || addOn.remaining ?? 0 > 0 | ||
|
||
// Assuming the user has not backed the addOn, we only display if it's within range of the start and end date | ||
let hasNoTimeLimitOrIsWithinRange = isStartDateBeforeToday(for: addOn) && isEndDateAfterToday(for: addOn) | ||
|
||
return [ | ||
project.state == .live, | ||
hasNoTimeLimitOrIsWithinRange, | ||
isUnlimitedOrAvailable | ||
] | ||
.allSatisfy(isTrue) | ||
return addOn.isAvailable ?? false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace all the start time logic with |
||
} | ||
|
||
private func filteredAddOns( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still formulating some thoughts about how we can replace the
Foo.template.lens |> ...
pattern, so I used this as an opportunity to actually get into the guts of one to learn more about it.