From b9133a87a2e8e3f5a2d41b5a0eaf5d69ed6e16de Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Fri, 15 Nov 2024 16:37:00 -0800 Subject: [PATCH 01/10] - Remove from project query the simpleShippingRules from rewards - In RewardsSelectionViewModel we fetch all rewards again with simpleShippingRules this time, but this information is not moved via intent to any other screen. --- app/src/main/graphql/fragments.graphql | 10 ------ app/src/main/graphql/project.graphql | 18 ++++++++++ .../mock/services/MockApolloClient.kt | 4 +++ .../kickstarter/services/KSApolloClientV2.kt | 35 +++++++++++++++++++ .../transformers/GraphQLTransformers.kt | 6 ++-- .../projectpage/RewardsSelectionViewModel.kt | 34 +++++++++++------- .../usecases/GetShippingRulesUseCase.kt | 9 +++-- 7 files changed, 85 insertions(+), 31 deletions(-) diff --git a/app/src/main/graphql/fragments.graphql b/app/src/main/graphql/fragments.graphql index 0b240ef644..72f539b8fa 100644 --- a/app/src/main/graphql/fragments.graphql +++ b/app/src/main/graphql/fragments.graphql @@ -115,16 +115,6 @@ fragment fullProject on Project { items { ... rewardItems } - ... on Reward { - simpleShippingRulesExpanded { - cost - country - estimatedMax - estimatedMin - locationId - locationName - } - } } } risks diff --git a/app/src/main/graphql/project.graphql b/app/src/main/graphql/project.graphql index 0058a3fd4c..dff91e594d 100644 --- a/app/src/main/graphql/project.graphql +++ b/app/src/main/graphql/project.graphql @@ -19,6 +19,24 @@ query FetchProject($slug: String!) { } } +query FetchProjectRewards($slug: String!) { + project(slug: $slug) { + rewards { + nodes { + ...reward + simpleShippingRulesExpanded { + cost + country + estimatedMax + estimatedMin + locationId + locationName + } + } + } + } +} + query ProjectCreatorDetails($slug: String!) { project(slug: $slug) { creator { diff --git a/app/src/main/java/com/kickstarter/mock/services/MockApolloClient.kt b/app/src/main/java/com/kickstarter/mock/services/MockApolloClient.kt index 5ed3ab1ccd..f1f6468557 100644 --- a/app/src/main/java/com/kickstarter/mock/services/MockApolloClient.kt +++ b/app/src/main/java/com/kickstarter/mock/services/MockApolloClient.kt @@ -62,6 +62,10 @@ import java.util.Collections open class MockApolloClientV2 : ApolloClientTypeV2 { + override fun getRewardsFromProject(slug: String): io.reactivex.Observable> { + TODO("Not yet implemented") + } + override fun watchProject(project: Project): io.reactivex.Observable { return io.reactivex.Observable.just(project.toBuilder().isStarred(true).build()) } diff --git a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt index 975f03e64d..fecc001998 100644 --- a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt +++ b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt @@ -15,6 +15,7 @@ import DeletePaymentSourceMutation import ErroredBackingsQuery import FetchCategoryQuery import FetchProjectQuery +import FetchProjectRewardsQuery import FetchProjectsQuery import GetBackingQuery import GetCommentQuery @@ -208,6 +209,7 @@ interface ApolloClientTypeV2 { fun createOrUpdateBackingAddress(eventInput: CreateOrUpdateBackingAddressData): Observable fun completeOrder(orderInput: CompleteOrderInput): Observable fun getPledgedProjectsOverviewPledges(inputData: PledgedProjectsOverviewQueryData): Observable + fun getRewardsFromProject(slug: String): Observable> } private const val PAGE_SIZE = 25 @@ -714,6 +716,39 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient }.subscribeOn(Schedulers.io()) } + override fun getRewardsFromProject(slug: String): Observable> { + return Observable.defer { + val ps = PublishSubject.create>() + val query = FetchProjectRewardsQuery.builder() + .slug(slug) + .build() + + this.service.query(query) + .enqueue(object : ApolloCall.Callback() { + override fun onFailure(e: ApolloException) { + ps.onError(e) + } + + override fun onResponse(response: Response) { + if (response.hasErrors()) { + ps.onError(Exception(response.errors?.first()?.message)) + } + response.data?.let { data -> + val rwList = data.project()?.rewards()?.nodes()?.map { + rewardTransformer( + rewardGr = it.fragments().reward(), + simpleShippingRules = it.simpleShippingRulesExpanded() + ) + } ?: emptyList() + ps.onNext(rwList) + } + ps.onComplete() + } + }) + return@defer ps + } + } + private fun getAddOnsFromProject(addOnsGr: GetProjectAddOnsQuery.AddOns): List { return addOnsGr.nodes()?.map { node -> val shippingRulesGr = diff --git a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt index 94ee86b1e9..fbd9cb99ed 100644 --- a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt +++ b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt @@ -130,7 +130,7 @@ fun environmentalCommitmentTransformer(envCommit: fragment.EnvironmentalCommitme fun rewardTransformer( rewardGr: fragment.Reward, shippingRulesExpanded: List = emptyList(), - simpleShippingRules: List = emptyList(), + simpleShippingRules: List = emptyList(), allowedAddons: Boolean = false, rewardItems: List = emptyList(), addOnItems: List = emptyList() @@ -198,7 +198,7 @@ fun rewardTransformer( .build() } -fun simpleShippingRuleTransformer(simpleShippingRules: FullProject.SimpleShippingRulesExpanded): ShippingRule { +fun simpleShippingRuleTransformer(simpleShippingRules: FetchProjectRewardsQuery.SimpleShippingRulesExpanded): ShippingRule { val id = decodeRelayId(simpleShippingRules.locationId()) ?: -1 val country = simpleShippingRules.country() ?: "" val displayName = simpleShippingRules.locationName() @@ -327,10 +327,8 @@ fun projectTransformer(projectFragment: FullProject?): Project { val minPledge = projectFragment?.minPledge()?.toDouble() ?: 1.0 val rewards = projectFragment?.rewards()?.nodes()?.map { - val shippingRules = it.simpleShippingRulesExpanded() rewardTransformer( it.fragments().reward(), - simpleShippingRules = shippingRules, allowedAddons = it.allowedAddons().pageInfo().startCursor()?.isNotEmpty() ?: false, rewardItems = complexRewardItemsTransformer(it.items()?.fragments()?.rewardItems()) ) diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt index e1747307c0..cc2cd42333 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt @@ -25,7 +25,10 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import kotlinx.coroutines.rx2.asFlow @@ -40,6 +43,7 @@ class RewardsSelectionViewModel(private val environment: Environment, private va private val analytics = requireNotNull(environment.analytics()) private val apolloClient = requireNotNull(environment.apolloClientV2()) + private val currentConfig = requireNotNull(environment.currentConfigV2()?.observable()) private lateinit var currentProjectData: ProjectData private var pReason: PledgeReason? = null @@ -90,19 +94,25 @@ class RewardsSelectionViewModel(private val environment: Environment, private va viewModelScope.launch { emitCurrentState() - environment.currentConfigV2()?.observable()?.asFlow()?.collectLatest { - if (shippingRulesUseCase == null) { - shippingRulesUseCase = GetShippingRulesUseCase( - projectData.project(), - it, - viewModelScope, - Dispatchers.IO - ) + apolloClient.getRewardsFromProject(projectData.project().slug() ?: "") + .asFlow() + .map { + it } - shippingRulesUseCase?.invoke() - - emitShippingUIState() - } + .combine(currentConfig.asFlow()) { rewardsList, config -> + if (shippingRulesUseCase == null) { + shippingRulesUseCase = GetShippingRulesUseCase( + project = projectData.project(), + config = config, + projectRewards = rewardsList.filter { it.isAvailable() }, + viewModelScope, + Dispatchers.IO + ) + } + shippingRulesUseCase?.invoke() + emitShippingUIState() + } + .collect() } } diff --git a/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt b/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt index 2aefc60b07..2d9beb858b 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt @@ -15,7 +15,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch data class ShippingRulesState( @@ -41,6 +40,7 @@ data class ShippingRulesState( class GetShippingRulesUseCase( private val project: Project, private val config: Config?, + private val projectRewards: List = emptyList(), private val scope: CoroutineScope, private val dispatcher: CoroutineDispatcher = Dispatchers.IO ) { @@ -49,7 +49,6 @@ class GetShippingRulesUseCase( private var defaultShippingRule = ShippingRule.builder().build() private var rewardsByShippingType: List private val allAvailableRulesForProject = mutableMapOf() - private val projectRewards = project.rewards()?.filter { RewardUtils.isNoReward(it) || it.isAvailable() } ?: listOf() init { @@ -57,15 +56,15 @@ class GetShippingRulesUseCase( val rewardsToQuery = mutableMapOf() // Get first reward with unrestricted shipping preference, when quering `getShippingRules` will return ALL available locations, no need to query more rewards locations - project.rewards()?.filter { RewardUtils.shipsWorldwide(reward = it) }?.firstOrNull()?.let { + projectRewards.filter { RewardUtils.shipsWorldwide(reward = it) }?.firstOrNull()?.let { rewardsToQuery.put(it.id(), it) } // In case there is no unrestricted preference need to get restricted and local rewards, to query their specific locations if (rewardsToQuery.isEmpty()) { - project.rewards()?.filter { + projectRewards.filter { RewardUtils.shipsToRestrictedLocations(reward = it) - }?.forEach { + }.forEach { rewardsToQuery[it.id()] = it } } From 2d96c82cf225d3384c659f403dfb4c98964b8bf1 Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 15:06:25 -0800 Subject: [PATCH 02/10] - Created separated query to obtain all rewards, will be called on RewardsSelectionVM - Removed from project query the rewards, only added the reward no reward with minimum pledge for a project. - When updating/managing a reward the information for reward/addons was collected from backing, therefore shippingRules was not available within baking that nested object. - Use as default the fresly queried information, and update with the backed information rather that the other way around. --- app/src/main/graphql/fragments.graphql | 13 ------------ app/src/main/graphql/project.graphql | 11 +++++++++- .../libs/utils/extensions/PledgeDataExt.kt | 2 +- .../kickstarter/services/KSApolloClientV2.kt | 9 ++++++++- .../transformers/GraphQLTransformers.kt | 15 +++----------- .../viewmodels/projectpage/AddOnsViewModel.kt | 15 ++++++++------ .../projectpage/CrowdfundCheckoutViewModel.kt | 6 ++++-- .../projectpage/RewardsSelectionViewModel.kt | 6 +++--- .../usecases/GetShippingRulesUseCase.kt | 20 +++++++++---------- .../services/GraphQLTransformersTest.kt | 2 +- 10 files changed, 49 insertions(+), 50 deletions(-) diff --git a/app/src/main/graphql/fragments.graphql b/app/src/main/graphql/fragments.graphql index 72f539b8fa..66516d0fc4 100644 --- a/app/src/main/graphql/fragments.graphql +++ b/app/src/main/graphql/fragments.graphql @@ -104,19 +104,6 @@ fragment fullProject on Project { prelaunchActivated ...tagsCreative ...tagsDiscovery - rewards { - nodes { - ... reward - allowedAddons { - pageInfo { - startCursor - } - } - items { - ... rewardItems - } - } - } risks story slug diff --git a/app/src/main/graphql/project.graphql b/app/src/main/graphql/project.graphql index dff91e594d..c8f94145be 100644 --- a/app/src/main/graphql/project.graphql +++ b/app/src/main/graphql/project.graphql @@ -21,9 +21,18 @@ query FetchProject($slug: String!) { query FetchProjectRewards($slug: String!) { project(slug: $slug) { + minPledge rewards { nodes { - ...reward + ... reward + allowedAddons { + pageInfo { + startCursor + } + } + items { + ... rewardItems + } simpleShippingRulesExpanded { cost country diff --git a/app/src/main/java/com/kickstarter/libs/utils/extensions/PledgeDataExt.kt b/app/src/main/java/com/kickstarter/libs/utils/extensions/PledgeDataExt.kt index 26c39f67ef..d54766c7e7 100644 --- a/app/src/main/java/com/kickstarter/libs/utils/extensions/PledgeDataExt.kt +++ b/app/src/main/java/com/kickstarter/libs/utils/extensions/PledgeDataExt.kt @@ -28,7 +28,7 @@ fun PledgeData.shippingCostIfShipping(): Double { var addOnsShippingCost = 0.0 this.addOns()?.map { if (RewardUtils.shipsWorldwide(it) || RewardUtils.shipsToRestrictedLocations(it)) { - addOnsShippingCost += (it.shippingRules()?.first()?.cost() ?: 0.0) * (it.quantity() ?: 0) + addOnsShippingCost += (it.shippingRules()?.firstOrNull()?.cost() ?: 0.0) * (it.quantity() ?: 0) } else 0.0 } diff --git a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt index fecc001998..1f14cfe756 100644 --- a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt +++ b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt @@ -53,6 +53,7 @@ import com.kickstarter.features.pledgedprojectsoverview.data.PledgedProjectsOver import com.kickstarter.libs.utils.extensions.isNotNull import com.kickstarter.libs.utils.extensions.toBoolean import com.kickstarter.libs.utils.extensions.toProjectSort +import com.kickstarter.mock.factories.RewardFactory import com.kickstarter.models.Backing import com.kickstarter.models.Category import com.kickstarter.models.Checkout @@ -737,10 +738,16 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient val rwList = data.project()?.rewards()?.nodes()?.map { rewardTransformer( rewardGr = it.fragments().reward(), + allowedAddons = it.allowedAddons().pageInfo().startCursor()?.isNotEmpty() ?: false, + rewardItems = complexRewardItemsTransformer(it.items()?.fragments()?.rewardItems()), simpleShippingRules = it.simpleShippingRulesExpanded() ) } ?: emptyList() - ps.onNext(rwList) + // - API does not provide the Reward no reward, we need to add it first + val minPledge = data.project()?.minPledge()?.toDouble() ?: 1.0 + val modifiedRewards = rwList.toMutableList() + modifiedRewards.add(0, RewardFactory.noReward().toBuilder().minimum(minPledge).build()) + ps.onNext(modifiedRewards.toList()) } ps.onComplete() } diff --git a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt index fbd9cb99ed..bc4018d5ac 100644 --- a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt +++ b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt @@ -325,19 +325,10 @@ fun projectTransformer(projectFragment: FullProject?): Project { projectFragment?.fragments()?.tagsDiscovery()?.tags()?.map { tags.add(it.id()) } val minPledge = projectFragment?.minPledge()?.toDouble() ?: 1.0 - val rewards = - projectFragment?.rewards()?.nodes()?.map { - rewardTransformer( - it.fragments().reward(), - allowedAddons = it.allowedAddons().pageInfo().startCursor()?.isNotEmpty() ?: false, - rewardItems = complexRewardItemsTransformer(it.items()?.fragments()?.rewardItems()) - ) - } // - GraphQL does not provide the Reward no reward, we need to add it first - val modifiedRewards = rewards?.toMutableList() - modifiedRewards?.add(0, RewardFactory.noReward().toBuilder().minimum(minPledge).build()) - modifiedRewards?.toList() + val modifiedRewards = emptyList().toMutableList() + modifiedRewards.add(0, RewardFactory.noReward().toBuilder().minimum(minPledge).build()) val slug = projectFragment?.slug() val staffPicked = projectFragment?.isProjectWeLove ?: false @@ -412,7 +403,7 @@ fun projectTransformer(projectFragment: FullProject?): Project { .sendMetaCapiEvents(sendMetaCapiEvents) .sendThirdPartyEvents(sendThirdPartyEvents) .tags(tags) - .rewards(modifiedRewards) + .rewards(modifiedRewards.toList()) .slug(slug) .staffPick(staffPicked) .state(state) diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/AddOnsViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/AddOnsViewModel.kt index c684bbe6fd..0796f2b3bf 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/AddOnsViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/AddOnsViewModel.kt @@ -150,7 +150,6 @@ class AddOnsViewModel(val environment: Environment, bundle: Bundle? = null) : Vi bonusAmount = b.amount() } else { backedAddOns = b.addOns() ?: emptyList() - currentUserReward = b.reward() ?: currentUserReward bonusAmount = b.bonusAmount() } } @@ -229,10 +228,14 @@ class AddOnsViewModel(val environment: Environment, bundle: Bundle? = null) : Vi holder[it.id()] = it } - // Take the backed AddOns, update with the backed AddOn information which will contain the backed quantity - backedAddOns.map { - holder[it.id()] = it - currentSelection[it.id()] = it.quantity() ?: 0 + // Take the backed AddOns, update with matching addOn ID with the quantity information + backedAddOns.map { backedAddOn -> + val aux = holder[backedAddOn.id()] + if (aux != null) { + val updated = aux.toBuilder().quantity(backedAddOn.quantity()).build() + holder[backedAddOn.id()] = updated + } + currentSelection[backedAddOn.id()] = backedAddOn.quantity() ?: 0 } return holder.values.toList() @@ -278,7 +281,7 @@ class AddOnsViewModel(val environment: Environment, bundle: Bundle? = null) : Vi val selectedAddOns = mutableListOf() addOns.forEach { val amount = currentSelection[it.id()] - if (amount != null) { + if (amount != null && amount > 0) { selectedAddOns.add(it.toBuilder().quantity(amount).build()) } } diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt index a7cc56f98b..3aad9a3ada 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt @@ -160,8 +160,10 @@ class CrowdfundCheckoutViewModel(val environment: Environment, bundle: Bundle? = when (flowContext) { PledgeFlowContext.NEW_PLEDGE, - PledgeFlowContext.CHANGE_REWARD -> getPledgeInfoFrom(pData) - PledgeFlowContext.MANAGE_REWARD, + PledgeFlowContext.CHANGE_REWARD, + PledgeFlowContext.MANAGE_REWARD -> { + getPledgeInfoFrom(pData) + } PledgeFlowContext.FIX_ERRORED_PLEDGE -> { backing?.let { getPledgeInfoFrom(it) } diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt index cc2cd42333..5f3b935d2c 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt @@ -91,10 +91,10 @@ class RewardsSelectionViewModel(private val environment: Environment, private va previousUserBacking == null && projectData.project().isInPostCampaignPledgingPhase() == false -> PledgeReason.PLEDGE else -> PledgeReason.PLEDGE } - + val project = projectData.project() viewModelScope.launch { emitCurrentState() - apolloClient.getRewardsFromProject(projectData.project().slug() ?: "") + apolloClient.getRewardsFromProject(project.slug() ?: "") .asFlow() .map { it @@ -104,7 +104,7 @@ class RewardsSelectionViewModel(private val environment: Environment, private va shippingRulesUseCase = GetShippingRulesUseCase( project = projectData.project(), config = config, - projectRewards = rewardsList.filter { it.isAvailable() }, + projectRewards = rewardsList, viewModelScope, Dispatchers.IO ) diff --git a/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt b/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt index 2d9beb858b..f0b4f88b32 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCase.kt @@ -53,23 +53,23 @@ class GetShippingRulesUseCase( init { // To avoid duplicates insert reward.id as key - val rewardsToQuery = mutableMapOf() + val rewardsToExtractLocation = mutableMapOf() // Get first reward with unrestricted shipping preference, when quering `getShippingRules` will return ALL available locations, no need to query more rewards locations projectRewards.filter { RewardUtils.shipsWorldwide(reward = it) }?.firstOrNull()?.let { - rewardsToQuery.put(it.id(), it) + rewardsToExtractLocation.put(it.id(), it) } // In case there is no unrestricted preference need to get restricted and local rewards, to query their specific locations - if (rewardsToQuery.isEmpty()) { + if (rewardsToExtractLocation.isEmpty()) { projectRewards.filter { RewardUtils.shipsToRestrictedLocations(reward = it) }.forEach { - rewardsToQuery[it.id()] = it + rewardsToExtractLocation[it.id()] = it } } - this.rewardsByShippingType = rewardsToQuery.values.toList() + this.rewardsByShippingType = rewardsToExtractLocation.values.toList() } // - Do not expose mutable states @@ -170,7 +170,7 @@ class GetShippingRulesUseCase( val isIsValidRule = allAvailableShippingRules[locationId] rewards.map { rw -> - if (RewardUtils.shipsWorldwide(rw)) { + if (RewardUtils.shipsWorldwide(rw) && rw.isAvailable()) { filteredRewards.add(rw) } @@ -178,16 +178,16 @@ class GetShippingRulesUseCase( filteredRewards.add(rw) } - if (RewardUtils.isLocalPickup(rw)) { + if (RewardUtils.isLocalPickup(rw) && rw.isAvailable()) { filteredRewards.add(rw) } - if (RewardUtils.isDigital(rw)) { + if (RewardUtils.isDigital(rw) && rw.isAvailable()) { filteredRewards.add(rw) } // - If shipping is restricted, make sure the reward is able to ship to selected rule - if (RewardUtils.shipsToRestrictedLocations(rw)) { + if (RewardUtils.shipsToRestrictedLocations(rw) && rw.isAvailable()) { if (isIsValidRule != null) { rw.shippingRules()?.map { if (it.location()?.id() == locationId) { @@ -214,7 +214,7 @@ class GetShippingRulesUseCase( val backing = project.backing() val locationId = project.backing()?.locationId() ?: 0L this.id(locationId) - val reward = backing?.reward()?.let { + backing?.reward()?.let { if (RewardUtils.shipsToRestrictedLocations(it)) { val rule = backing?.reward()?.shippingRules() ?.first { it.location()?.id() == locationId } diff --git a/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt b/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt index 52208cb093..6c3b19f92e 100644 --- a/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt +++ b/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt @@ -187,7 +187,7 @@ class GraphQLTransformersTest : KSRobolectricTestCase() { @Test fun `test simpleShippingRuleTransformer provides appropriate shippingRule`() { - val canadaSimpleSR = FullProject.SimpleShippingRulesExpanded( + val canadaSimpleSR = Reward.SimpleShippingRulesExpanded( "SimpleShippingRule", "17.34562379823645234875620384756203847234", "CA", From 53039333de4a3b095eb8ed3efe5224d84467e291 Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 15:19:41 -0800 Subject: [PATCH 03/10] - Tests --- .../kickstarter/services/GraphQLTransformersTest.kt | 11 +++++------ .../viewmodels/RewardsSelectionViewModelTest.kt | 12 +++++++----- .../usecases/GetShippingRulesUseCaseTest.kt | 7 ++++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt b/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt index 6c3b19f92e..e8e4fc23ff 100644 --- a/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt +++ b/app/src/test/java/com/kickstarter/services/GraphQLTransformersTest.kt @@ -15,7 +15,6 @@ import fragment.AiDisclosure import fragment.Amount import fragment.EnvironmentalCommitment import fragment.Faq -import fragment.FullProject import fragment.Reward import fragment.Reward.AllowedAddons import fragment.User @@ -187,7 +186,7 @@ class GraphQLTransformersTest : KSRobolectricTestCase() { @Test fun `test simpleShippingRuleTransformer provides appropriate shippingRule`() { - val canadaSimpleSR = Reward.SimpleShippingRulesExpanded( + val canadaSimpleSR = FetchProjectRewardsQuery.SimpleShippingRulesExpanded( "SimpleShippingRule", "17.34562379823645234875620384756203847234", "CA", @@ -197,7 +196,7 @@ class GraphQLTransformersTest : KSRobolectricTestCase() { "Canada" ) - val australiaSR = FullProject.SimpleShippingRulesExpanded( + val australiaSR = FetchProjectRewardsQuery.SimpleShippingRulesExpanded( "SimpleShippingRule", "0", "AU", @@ -207,7 +206,7 @@ class GraphQLTransformersTest : KSRobolectricTestCase() { "Australia" ) - val forbiddenValues = FullProject.SimpleShippingRulesExpanded( + val forbiddenValues = FetchProjectRewardsQuery.SimpleShippingRulesExpanded( "SimpleShippingRule", "Pikachusito", "AU", @@ -287,7 +286,7 @@ class GraphQLTransformersTest : KSRobolectricTestCase() { @Test fun `test rewardTransformer returns appropriate shippingRules field when querying for simpleShippingRulesExpanded`() { - val canadaSimpleSR = FullProject.SimpleShippingRulesExpanded( + val canadaSimpleSR = FetchProjectRewardsQuery.SimpleShippingRulesExpanded( "SimpleShippingRule", "17.34562379823645234875620384756203847234", "CA", @@ -297,7 +296,7 @@ class GraphQLTransformersTest : KSRobolectricTestCase() { "Canada" ) - val australiaSR = FullProject.SimpleShippingRulesExpanded( + val australiaSR = FetchProjectRewardsQuery.SimpleShippingRulesExpanded( "SimpleShippingRule", "0", "AU", diff --git a/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt index b1e8557518..89be32f2d4 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt @@ -351,7 +351,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { val shippingUiState = mutableListOf() backgroundScope.launch(dispatcher) { - val useCase = GetShippingRulesUseCase(testProject, config, this, dispatcher) + val useCase = GetShippingRulesUseCase(testProject, config, testRewards, this, dispatcher) createViewModel(env, useCase) viewModel.provideProjectData(testProjectData) @@ -449,8 +449,9 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { .locationName(testShippingRulesList.first().location()?.displayableName()) .build() + val rwList = listOf(rw1, rw2, rw3) val project = ProjectFactory.project().toBuilder() - .rewards(listOf(rw1, rw2, rw3)) + .rewards(rwList) .backing(backing) .isBacking(true) .build() @@ -470,7 +471,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { val dispatcher = UnconfinedTestDispatcher(testScheduler) val shippingUiState = mutableListOf() backgroundScope.launch(dispatcher) { - val useCase = GetShippingRulesUseCase(project, config, this, dispatcher) + val useCase = GetShippingRulesUseCase(project, config, rwList, this, dispatcher) createViewModel(env, useCase) viewModel.provideProjectData(projectData) viewModel.shippingUIState.toList(shippingUiState) @@ -495,7 +496,8 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { .shippingRules(testShippingRulesList.shippingRules()) .build() val user = UserFactory.user() - val project = ProjectFactory.project().toBuilder().rewards(listOf(rw, rw, rw)).build() + val rwList = listOf(rw, rw, rw) + val project = ProjectFactory.project().toBuilder().rewards(rwList).build() val projectData = ProjectDataFactory.project(project, null, null) val config = ConfigFactory.configForCA() @@ -511,7 +513,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { val dispatcher = UnconfinedTestDispatcher(testScheduler) val shippingUiState = mutableListOf() backgroundScope.launch(dispatcher) { - val useCase = GetShippingRulesUseCase(project, config, this, dispatcher) + val useCase = GetShippingRulesUseCase(project, config, rwList, this, dispatcher) createViewModel(env, useCase) viewModel.provideProjectData(projectData) viewModel.shippingUIState.toList(shippingUiState) diff --git a/app/src/test/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCaseTest.kt b/app/src/test/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCaseTest.kt index fb0a3b14f3..e3215d2604 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCaseTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/usecases/GetShippingRulesUseCaseTest.kt @@ -33,7 +33,7 @@ class GetShippingRulesUseCaseTest : KSRobolectricTestCase() { val dispatcher = UnconfinedTestDispatcher(testScheduler) val scope = backgroundScope - val useCase = GetShippingRulesUseCase(project, config, scope, dispatcher) + val useCase = GetShippingRulesUseCase(project, config, project.rewards() ?: emptyList(), scope, dispatcher) val state = mutableListOf() scope.launch(dispatcher) { @@ -66,9 +66,10 @@ class GetShippingRulesUseCaseTest : KSRobolectricTestCase() { .shippingRules(listOf(shippingRule1, shippingRule2, shippingRule3)) .build() + val rwList = listOf(reward, reward2) val project = ProjectFactory.project() .toBuilder() - .rewards(listOf(reward, reward2)) + .rewards(rwList) .state(Project.STATE_SUCCESSFUL) .isInPostCampaignPledgingPhase(true) .postCampaignPledgingEnabled(true) @@ -77,7 +78,7 @@ class GetShippingRulesUseCaseTest : KSRobolectricTestCase() { val dispatcher = UnconfinedTestDispatcher(testScheduler) val scope = backgroundScope - val useCase = GetShippingRulesUseCase(project, config, scope, dispatcher) + val useCase = GetShippingRulesUseCase(project, config, rwList, scope, dispatcher) val state = mutableListOf() scope.launch(dispatcher) { From c0c0badd0084bf0dc6419b387aaea809100480ed Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 18:22:50 -0800 Subject: [PATCH 04/10] - Added back rewards on project query, as the the backed reward information to who "change payment method"/ "Fix Pledge" do require the rewards information for the project --- app/src/main/graphql/fragments.graphql | 5 +++++ .../services/transformers/GraphQLTransformers.kt | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/graphql/fragments.graphql b/app/src/main/graphql/fragments.graphql index 66516d0fc4..6c4e036d14 100644 --- a/app/src/main/graphql/fragments.graphql +++ b/app/src/main/graphql/fragments.graphql @@ -104,6 +104,11 @@ fragment fullProject on Project { prelaunchActivated ...tagsCreative ...tagsDiscovery + rewards { # query within project the bare minimum for rewards + nodes { + ... reward + } + } risks story slug diff --git a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt index bc4018d5ac..130a65dd9a 100644 --- a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt +++ b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt @@ -325,10 +325,17 @@ fun projectTransformer(projectFragment: FullProject?): Project { projectFragment?.fragments()?.tagsDiscovery()?.tags()?.map { tags.add(it.id()) } val minPledge = projectFragment?.minPledge()?.toDouble() ?: 1.0 + val rewards = + projectFragment?.rewards()?.nodes()?.map { + rewardTransformer( + it.fragments().reward() + ) + } // - GraphQL does not provide the Reward no reward, we need to add it first - val modifiedRewards = emptyList().toMutableList() - modifiedRewards.add(0, RewardFactory.noReward().toBuilder().minimum(minPledge).build()) + val modifiedRewards = rewards?.toMutableList() + modifiedRewards?.add(0, RewardFactory.noReward().toBuilder().minimum(minPledge).build()) + modifiedRewards?.toList() val slug = projectFragment?.slug() val staffPicked = projectFragment?.isProjectWeLove ?: false @@ -403,7 +410,7 @@ fun projectTransformer(projectFragment: FullProject?): Project { .sendMetaCapiEvents(sendMetaCapiEvents) .sendThirdPartyEvents(sendThirdPartyEvents) .tags(tags) - .rewards(modifiedRewards.toList()) + .rewards(modifiedRewards) .slug(slug) .staffPick(staffPicked) .state(state) From 38497bb1939609efebaa6f99c54b925ee65730f0 Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 19:19:54 -0800 Subject: [PATCH 05/10] - Use pledgeReason, PledgeFlowContext will never present "Change Reward", but always for fixing changing payment method AND choosing another reward it will show "Manage pledge" --- .../projectpage/CrowdfundCheckoutViewModel.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt index 3aad9a3ada..c4a3ce45f9 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt @@ -146,7 +146,6 @@ class CrowdfundCheckoutViewModel(val environment: Environment, bundle: Bundle? = fun provideBundle(arguments: Bundle?) { val pData = arguments?.getParcelable(ArgumentsKey.PLEDGE_PLEDGE_DATA) as PledgeData? pledgeReason = arguments?.getSerializable(ArgumentsKey.PLEDGE_PLEDGE_REASON) as PledgeReason? - val flowContext = pledgeReason?.let { PledgeFlowContext.forPledgeReason(it) } if (pData != null) { pledgeData = pData @@ -158,14 +157,12 @@ class CrowdfundCheckoutViewModel(val environment: Environment, bundle: Bundle? = sharedPreferences ) - when (flowContext) { - PledgeFlowContext.NEW_PLEDGE, - PledgeFlowContext.CHANGE_REWARD, - PledgeFlowContext.MANAGE_REWARD -> { - getPledgeInfoFrom(pData) - } - PledgeFlowContext.FIX_ERRORED_PLEDGE - -> { + when (pledgeReason) { + PledgeReason.PLEDGE, + PledgeReason.UPDATE_PLEDGE, + PledgeReason.UPDATE_REWARD -> getPledgeInfoFrom(pData) + PledgeReason.UPDATE_PAYMENT, + PledgeReason.FIX_PLEDGE -> { backing?.let { getPledgeInfoFrom(it) } } else -> { From a4c46255c8d78c91759cca90ccb18c98ff931352 Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 19:27:13 -0800 Subject: [PATCH 06/10] no message --- .../kickstarter/viewmodels/projectpage/ProjectPageViewModel.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/ProjectPageViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/ProjectPageViewModel.kt index 0c58cc05b4..951d068616 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/ProjectPageViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/ProjectPageViewModel.kt @@ -1028,7 +1028,6 @@ interface ProjectPageViewModel { .addToDisposable(disposables) this.updatePledgeData - .distinctUntilChanged() .subscribe { this.showUpdatePledge.onNext(it) }.addToDisposable(disposables) From 94df6a6d5c22338151bdf226d4b29d12cd05c238 Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 19:36:55 -0800 Subject: [PATCH 07/10] - Tests! --- .../java/com/kickstarter/mock/services/MockApolloClientV2.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/kickstarter/mock/services/MockApolloClientV2.kt b/app/src/main/java/com/kickstarter/mock/services/MockApolloClientV2.kt index 394718b232..abf3efb5e8 100644 --- a/app/src/main/java/com/kickstarter/mock/services/MockApolloClientV2.kt +++ b/app/src/main/java/com/kickstarter/mock/services/MockApolloClientV2.kt @@ -54,7 +54,7 @@ import java.util.Collections open class MockApolloClientV2 : ApolloClientTypeV2 { override fun getRewardsFromProject(slug: String): io.reactivex.Observable> { - TODO("Not yet implemented") + return io.reactivex.Observable.just(emptyList()) } override fun watchProject(project: Project): io.reactivex.Observable { From 5c08ff9c555a3c66c3125a6499f47b5295cba9ee Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Mon, 18 Nov 2024 19:44:59 -0800 Subject: [PATCH 08/10] no message --- .../viewmodels/projectpage/RewardsSelectionViewModel.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt index 5f3b935d2c..d223a27ab1 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt @@ -25,10 +25,10 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import kotlinx.coroutines.rx2.asFlow @@ -36,7 +36,7 @@ import kotlinx.coroutines.rx2.asFlow data class RewardSelectionUIState( val selectedReward: Reward = Reward.builder().build(), val initialRewardIndex: Int = 0, - val project: ProjectData = ProjectData.builder().build(), + val project: ProjectData = ProjectData.builder().build() ) class RewardsSelectionViewModel(private val environment: Environment, private var shippingRulesUseCase: GetShippingRulesUseCase? = null) : ViewModel() { @@ -96,9 +96,6 @@ class RewardsSelectionViewModel(private val environment: Environment, private va emitCurrentState() apolloClient.getRewardsFromProject(project.slug() ?: "") .asFlow() - .map { - it - } .combine(currentConfig.asFlow()) { rewardsList, config -> if (shippingRulesUseCase == null) { shippingRulesUseCase = GetShippingRulesUseCase( @@ -112,6 +109,7 @@ class RewardsSelectionViewModel(private val environment: Environment, private va shippingRulesUseCase?.invoke() emitShippingUIState() } + .catch { } .collect() } } From db789ed1e3ef48931f1767716c865260ae0da22c Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Tue, 19 Nov 2024 10:55:39 -0800 Subject: [PATCH 09/10] - "Update_PLEDGE" will never show the rewards carousel, "Update_Pledge" option was removed from the menu --- .../viewmodels/projectpage/CrowdfundCheckoutViewModel.kt | 1 - .../viewmodels/projectpage/RewardsSelectionViewModel.kt | 4 ++-- .../kickstarter/viewmodels/RewardsSelectionViewModelTest.kt | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt index c4a3ce45f9..e1dab951e5 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/CrowdfundCheckoutViewModel.kt @@ -159,7 +159,6 @@ class CrowdfundCheckoutViewModel(val environment: Environment, bundle: Bundle? = when (pledgeReason) { PledgeReason.PLEDGE, - PledgeReason.UPDATE_PLEDGE, PledgeReason.UPDATE_REWARD -> getPledgeInfoFrom(pData) PledgeReason.UPDATE_PAYMENT, PledgeReason.FIX_PLEDGE -> { diff --git a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt index d223a27ab1..661a578f70 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/projectpage/RewardsSelectionViewModel.kt @@ -87,7 +87,7 @@ class RewardsSelectionViewModel(private val environment: Environment, private va indexOfBackedReward = indexOfBackedReward(project = projectData.project()) pReason = when { previousUserBacking == null && projectData.project().isInPostCampaignPledgingPhase() == true -> PledgeReason.LATE_PLEDGE - previousUserBacking != null -> PledgeReason.UPDATE_PLEDGE + previousUserBacking != null -> PledgeReason.UPDATE_REWARD previousUserBacking == null && projectData.project().isInPostCampaignPledgingPhase() == false -> PledgeReason.PLEDGE else -> PledgeReason.PLEDGE } @@ -217,7 +217,7 @@ class RewardsSelectionViewModel(private val environment: Environment, private va fun shouldShowAlert(): Boolean { val prevRw = previousUserBacking?.reward() prevRw?.let { - if (pReason == PledgeReason.UPDATE_PLEDGE) { + if (pReason == PledgeReason.UPDATE_REWARD) { return !previousUserBacking?.addOns().isNullOrEmpty() && prevRw.id() != newUserReward.id() } } diff --git a/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt index 89be32f2d4..e2eed88c83 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/RewardsSelectionViewModelTest.kt @@ -527,7 +527,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { } @Test - fun `When user is updating pledge, if selecting a different reward and had addOns backed, show alert`() = runTest { + fun `When user is updating reward selection, if selecting a different reward and had addOns backed, show alert`() = runTest { val reward = RewardFactory.digitalReward() val addOns = listOf(RewardFactory.reward(), RewardFactory.addOnMultiple()) val backing = Backing.builder() @@ -555,7 +555,7 @@ class RewardsSelectionViewModelTest : KSRobolectricTestCase() { advanceUntilIdle() // wait until all state emissions completed assertEquals(viewModel.shouldShowAlert(), true) - assertEquals(viewModel.getPledgeData()?.second, PledgeReason.UPDATE_PLEDGE) + assertEquals(viewModel.getPledgeData()?.second, PledgeReason.UPDATE_REWARD) } @Test From e4a78e54eaf2c080b5b9d3fc2937330914133218 Mon Sep 17 00:00:00 2001 From: Isa Martin Date: Tue, 19 Nov 2024 11:06:10 -0800 Subject: [PATCH 10/10] - Added your selection tag for reward no reward --- .../ui/activities/compose/projectpage/RewardCarouselScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/kickstarter/ui/activities/compose/projectpage/RewardCarouselScreen.kt b/app/src/main/java/com/kickstarter/ui/activities/compose/projectpage/RewardCarouselScreen.kt index b42dd70a6a..0d05f35b3c 100644 --- a/app/src/main/java/com/kickstarter/ui/activities/compose/projectpage/RewardCarouselScreen.kt +++ b/app/src/main/java/com/kickstarter/ui/activities/compose/projectpage/RewardCarouselScreen.kt @@ -220,7 +220,8 @@ fun RewardCarouselScreen( id = R.string.Back_it_because_you_believe_in_it ), onRewardSelectClicked = { onRewardSelected(reward) }, - isCTAButtonVisible = project.isAllowedToPledge() + isCTAButtonVisible = project.isAllowedToPledge(), + yourSelectionIsVisible = project.backing()?.isBacked(reward) ?: false, ) } else { KSRewardCard(