[MOB-4179] Update Seeds with balance account#1048
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Ecosia account UI seed display to align iOS with Web by using the “current spendable seeds” balance rather than the lifetime seeds total.
Changes:
- Switch seed count source in
EcosiaAuthUIStateProvider.updateBalancefromseeds.totalAmounttoseeds.balanceAmount.
Comments suppressed due to low confidence (1)
firefox-ios/Ecosia/UI/Account/EcosiaAuthUIStateProvider.swift:262
newSeedCountis now based onresponse.seeds.balanceAmount, but the animation still usesresponse.seedsIncrement, which is computed fromseeds.totalAmount - seeds.previousTotalAmountinAccountVisitResponse. If total and balance diverge (e.g., after spending seeds), the displayed increment can be incorrect. Consider computing the increment from the balance values (e.g.,newSeedCount - seedCount, only when positive) or adding a dedicatedbalanceIncrementin the response model and using that here.
let newSeedCount = response.seeds.balanceAmount
let newLevelNumber = response.growthPoints.level.number
let newProgress = response.progressToNextLevel
// Update level and progress from API
currentLevelNumber = newLevelNumber
currentProgress = newProgress
// Trigger level-up animation if user leveled up
if response.didLevelUp {
EcosiaLogger.accounts.info("Level up detected: triggering animation for level \(newLevelNumber)")
triggerLevelUpAnimation()
}
if let increment = response.seedsIncrement {
EcosiaLogger.accounts.info("Balance updated with animation: \(seedCount) → \(newSeedCount) (+\(increment)), level=\(newLevelNumber), progress=\(newProgress)")
animateBalanceChange(from: seedCount, to: newSeedCount, increment: increment)
| let newSeedCount = response.seeds.balanceAmount | ||
| let newLevelNumber = response.growthPoints.level.number |
There was a problem hiding this comment.
PR description says the app should move from seeds.totalAmount to seeds.balanceAmount, but this change only updates EcosiaAuthUIStateProvider. Other call sites still use totalAmount (e.g., EcosiaAccountAvatarViewModel.updateFromBalanceResponse and AccountsService logging), which can keep parts of the UI/telemetry out of sync. Either update those call sites in this PR as well or clarify in the description why only this view state should use balanceAmount.
There was a problem hiding this comment.
This seems relevant? We now only use the total to calculate the user's level, and I think you can just grab their level directly. I'm not sure you'd ever have a case to use the total anymore.
There was a problem hiding this comment.
Mmmmh I agree it is, technically they should all be aligned. Either by grabbing the value from the EcosiaAuthUIStateProvider or by the response API itself. @copilot suggest a change.
* Initial plan * Align all seed count call sites to use balanceAmount Co-authored-by: d4r1091 <3584008+d4r1091@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: d4r1091 <3584008+d4r1091@users.noreply.github.com>
* [MOB-4179] Update Seeds with balance account * Align all seed count call sites to use `balanceAmount` (#1049) * Initial plan * Align all seed count call sites to use balanceAmount Co-authored-by: d4r1091 <3584008+d4r1091@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: d4r1091 <3584008+d4r1091@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: d4r1091 <3584008+d4r1091@users.noreply.github.com>
MOB-4179
Context
We noticed an out-of-sync behaviour between iOS native and Web.
After an investigation, JOU noticed that with the Collectibles release, they switched from displaying seeds total (all seeds ever earned) to seeds balance (current seeds value available to spend after buying collectibles).
Approach
Other
Before merging
Checklist