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

[MOB 1953] Separate search and referral impact #568

Merged
merged 8 commits into from
Oct 11, 2023

Conversation

lucaschifino
Copy link
Collaborator

@lucaschifino lucaschifino commented Oct 6, 2023

MOB-1953

Context

We'll no longer have one global counter to rule them all, we'll instead separate into search and referral impact counters.

Core-side counterpart: https://github.com/ecosia/ios-core/pull/115

Approach

  • Use User.shared.searchImpact instead of User.shared.impact
  • Refactor ClimateImpactInfo so it is more clear the existence of two separate impact counter
    • Also correctly enabling referrals impact having a different value than invited friends (both were using User.shared.referrals.count and none User.shared.referrals.impact)
  • Update some names to match renamings mad on ios-core
  • Update referral page UI to match NTP's referral counter

@lucaschifino lucaschifino requested a review from a team October 9, 2023 08:29
@lucaschifino lucaschifino marked this pull request as ready for review October 10, 2023 13:04
let info = ClimateImpactInfo.referral(value: User.shared.referrals.impact,
invites: User.shared.referrals.count)
let view = NTPImpactRowView(info: info)
view.info = info // Needed to force info setup after init
Copy link
Member

@d4r1091 d4r1091 Oct 10, 2023

Choose a reason for hiding this comment

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

Interested to get more insights on this one. Is it strictly needed?
I tried to put a breakpoint in the didSet of that var info: ClimateImpactInfo and seems like it gets there even without re-assigning the value here.
Also, if the intent is to reassign after the init, I was wondering whether something like this 👇 in the NTPImpactRowView.init would work as well:

defer {
    self.info = info
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It unfortunately is, this basically resulted from the fact that I prepared the view to automatically refresh every time the info changes. It initially was not even passed on init (mimicking the behaviour of a cell that is configured afterwards), but I had to pass it solely to support the existence of the progress bar.

You are right that didSet is in fact already called, but for some reason that is not the correct point in the lifecycle for it to properly update. defer is an interesting suggestion and should in fact work, I can try it since it seems less error prone 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It also works with the defer, just updated it, thanks for the suggestion ❤️

@lucaschifino lucaschifino requested review from d4r1091 and a team October 10, 2023 15:33
d4r1091
d4r1091 previously approved these changes Oct 11, 2023
Copy link
Member

@d4r1091 d4r1091 left a comment

Choose a reason for hiding this comment

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

LGTM 🟢

@lucaschifino
Copy link
Collaborator Author

@d4r1091 had to fix a merge conflict, can you check again for another 👍 ?

@lucaschifino lucaschifino requested a review from d4r1091 October 11, 2023 09:36
Copy link
Member

@d4r1091 d4r1091 left a comment

Choose a reason for hiding this comment

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

Another 👍

@lucaschifino lucaschifino merged commit dada9b7 into main Oct 11, 2023
@lucaschifino lucaschifino deleted the MOB-1953_separate_search_and_referral_impact branch October 11, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants