Skip to content

[MOB-4179] Update Seeds with balance account#1048

Merged
d4r1091 merged 2 commits intomainfrom
dc-mob-4179-update-balance
Feb 20, 2026
Merged

[MOB-4179] Update Seeds with balance account#1048
d4r1091 merged 2 commits intomainfrom
dc-mob-4179-update-balance

Conversation

@d4r1091
Copy link
Copy Markdown
Member

@d4r1091 d4r1091 commented Feb 20, 2026

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

  • Move from seeds.totalAmount to seeds.balanceAmount

Other

Before merging

Checklist

  • I performed some relevant testing on a real device and/or simulator for both iPhone and iPad

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.updateBalance from seeds.totalAmount to seeds.balanceAmount.
Comments suppressed due to low confidence (1)

firefox-ios/Ecosia/UI/Account/EcosiaAuthUIStateProvider.swift:262

  • newSeedCount is now based on response.seeds.balanceAmount, but the animation still uses response.seedsIncrement, which is computed from seeds.totalAmount - seeds.previousTotalAmount in AccountVisitResponse. 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 dedicated balanceIncrement in 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)

Comment on lines +246 to 247
let newSeedCount = response.seeds.balanceAmount
let newLevelNumber = response.growthPoints.level.number
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Copilot AI commented Feb 20, 2026

@d4r1091 I've opened a new pull request, #1049, to work on those changes. Once the pull request is ready, I'll request review from you.

* 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>
@d4r1091 d4r1091 merged commit f001f97 into main Feb 20, 2026
3 checks passed
@d4r1091 d4r1091 deleted the dc-mob-4179-update-balance branch February 20, 2026 20:42
d4r1091 added a commit that referenced this pull request Mar 2, 2026
* [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>
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.

5 participants