Skip to content

Commit

Permalink
Do not show Winback offer if there is no active purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
MiSikora committed Feb 7, 2025
1 parent 344d205 commit 378c098
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,10 @@ class WinbackViewModel @Inject constructor(
}

private fun UiState.applyWinbackResponse(response: WinbackResponse?): UiState {
val activePurchase = (subscriptionPlansState as? SubscriptionPlansState.Loaded)?.activePurchase
return copy(
winbackOfferState = response
?.takeIf { activePurchase != null }
?.toWinbackOffer(productsDetails)
?.let(::WinbackOfferState),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,7 @@ class WinbackViewModelTest {
assertNull(changedPlanState.winbackOfferState)

winbackManager.addWinbackResponse(winbackResponse)
assertEquals(
"offer-token-${Subscription.PLUS_MONTHLY_PRODUCT_ID}",
awaitOfferState().offer.offerToken,
)
expectNoEvents()
}
}

Expand Down

0 comments on commit 378c098

Please sign in to comment.