Skip to content
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-1317] Show Rewards Based on Reward.isAvailable #2014

Merged
merged 13 commits into from Apr 4, 2024

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Apr 2, 2024

πŸ“² What

Uses the isAvailable property on Rewards to determine reward availability and UI.

πŸ€” Why

Right now, unavailable late pledge rewards are being shown as available πŸ‘Ž
The expected UX is to show unavailable rewards, but they should be marked as such ("no longer available"), not tappable, and appear at the end of the rewards collection.

πŸ›  How

More in-depth discussion of the change or implementation.

πŸ‘€ See

Unavailable rewards are marked as (no late pledge) in their title πŸ˜„

Simulator Screen Recording - iPhone 15 Pro Max - 2024-04-02 at 11 51 36

βœ… Acceptance criteria

  • Unavailable rewards are displayed as such and aren't tappable
  • Available rewards show up at the beginning of the collection and are selectable as usual
  • Normal, non-late-pledge rewards behavior is unchanged.

@scottkicks scottkicks self-assigned this Apr 2, 2024
@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch 2 times, most recently from 44a9373 to 957ddee Compare April 2, 2024 16:57
// Both types of availability must be valid in order for this reward to be considered available.
return limitedAvailabilityValid && timebasedAvailabilityValid
public func rewardIsAvailable(_ reward: Reward) -> Bool {
reward.isAvailable == true || reward.isNoReward
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The no reward ("$1 Pledge without a reward") option is always available. The backend isn't controlling the isAvailable value for these, so I'm forcing it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of setting isAvailable = true when the no reward reward is created instead? That feels cleaner to me.

@scottkicks
Copy link
Contributor Author

Tests are passing locally for me but not on CI πŸ€”

@scottkicks scottkicks marked this pull request as ready for review April 2, 2024 17:20
Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, you should be able to have fewer isAvailable setters now.

@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch 2 times, most recently from 11a7ad0 to 2a7b398 Compare April 2, 2024 18:28
@kickstarter kickstarter deleted a comment from nativeksr Apr 2, 2024
@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch 6 times, most recently from e99566a to acc13fc Compare April 2, 2024 23:07
@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch from 7f2f147 to 82d1d9a Compare April 3, 2024 13:39
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-recorded this snapshot to get it to pass. The only visible difference is the order, which by the looks of the original snapshot, wasn't correct to begin with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting changes that I can't seem to avoid. likely related to our discussion here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottkicks So you can avoid these, but it's a little annoying - unstage them from the commit, and instead do git commit -m "whatever your commit was" --no-verify. My preference would be for us to solve this in its own PR, if we can, since it's such a weird and separate issue.

@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch from dfa1cdb to af65f22 Compare April 3, 2024 14:34
@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch from af65f22 to 21bd8d3 Compare April 3, 2024 15:16
@@ -163,8 +163,7 @@ private let cosmicSurgeryRewards: [Reward] = [
|> Reward.lens
.description .~
"You will be the first to receive a copy of the book at this special β€˜earlybird’ price. Limited to the first 100 copies."
|> Reward.lens.localPickup .~ nil
|> Reward.lens.isAvailable .~ true,
Copy link
Contributor Author

@scottkicks scottkicks Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing this reward to available seems to break the testRewards_Backer_LiveProject_Landscape.lang_es_device_phone5_8inch test. Removing

* This is ok because we're testing that updated values don't impact whether rewards are shown or now. Just that they are shown with the correct data
Comment on lines 165 to 166
func testConfigureWithProject_LocalPickupRewards_NonLocalPickupRewards_IncludiongNonLocalBackedReward_ShowsAllRewards_Success() {
let rewards = Project.cosmicSurgery.rewards
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also fixed a typo

Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM but there are two things in here that should be pulled out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks unncessary, can you pull it out?

@@ -26,7 +26,8 @@ extension Project {
dates: Project.Dates(
deadline: Date(timeIntervalSince1970: 1_475_361_315).timeIntervalSince1970 + 60.0 * 60.0 * 24.0 * 15.0,
featuredAt: nil,
launchedAt: Date(timeIntervalSince1970: 1_475_361_315).timeIntervalSince1970 - 60.0 * 60.0 * 24.0 * 15.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you unstage this change from the PR? It's fixed in #2020

@scottkicks scottkicks force-pushed the feat/scott/mbl-1317/fix-unavailable-rewards branch from 0587d00 to 48a3470 Compare April 4, 2024 13:32
@kickstarter kickstarter deleted a comment from nativeksr Apr 4, 2024
@scottkicks scottkicks merged commit fd1a221 into main Apr 4, 2024
5 checks passed
@scottkicks scottkicks deleted the feat/scott/mbl-1317/fix-unavailable-rewards branch April 4, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants