Skip to content

Commit

Permalink
Shared: Fix subscription management is not available for MobileConten…
Browse files Browse the repository at this point in the history
…tTrial subscription (#1144)

^ALTAPPS-1317
  • Loading branch information
XanderZhu authored Aug 5, 2024
1 parent 984fa60 commit 5aadab9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ internal class ProfileSettingsReducer : StateReducer<State, Message, Action> {
state: State
): ReducerResult =
if (state is State.Content) {
state to when (state.subscription?.type) {
SubscriptionType.MOBILE_ONLY ->
state to when {
state.subscription?.type == SubscriptionType.MOBILE_ONLY ->
setOf(
Action.LogAnalyticEvent(
ProfileSettingsClickedHyperskillAnalyticEvent(
Expand All @@ -199,7 +199,7 @@ internal class ProfileSettingsReducer : StateReducer<State, Message, Action> {
),
Action.ViewAction.NavigateTo.SubscriptionManagement
)
SubscriptionType.FREEMIUM ->
state.subscription?.type?.canUpgradeToMobileOnly == true ->
setOf(
Action.LogAnalyticEvent(
ProfileSettingsClickedHyperskillAnalyticEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,25 @@ internal class ProfileSettingsViewStateMapper(
ViewState.Content(
profileSettings = state.profileSettings,
isLoadingMagicLink = state.isLoadingMagicLink,
subscriptionState = if (isSubscriptionVisible(state)) {
when (state.subscription?.type) {
SubscriptionType.MOBILE_ONLY ->
subscriptionState = if (state.subscription != null && state.mobileOnlyFormattedPrice != null) {
when {
state.subscription.type == SubscriptionType.MOBILE_ONLY -> {
ViewState.Content.SubscriptionState(
resourceProvider.getString(SharedResources.strings.settings_subscription_mobile_only)
)
SubscriptionType.FREEMIUM -> {
state.mobileOnlyFormattedPrice?.let {
ViewState.Content.SubscriptionState(
resourceProvider.getString(
SharedResources.strings.settings_subscription_mobile_only_suggestion,
state.mobileOnlyFormattedPrice
)
}
state.subscription.type.canUpgradeToMobileOnly -> {
ViewState.Content.SubscriptionState(
resourceProvider.getString(
SharedResources.strings.settings_subscription_mobile_only_suggestion,
state.mobileOnlyFormattedPrice
)
}
)
}
else -> null
}
} else {
null
}
)

private fun isSubscriptionVisible(state: ProfileSettingsFeature.State.Content): Boolean =
state.subscription != null &&
state.mobileOnlyFormattedPrice != null &&
when (state.subscription.type) {
SubscriptionType.FREEMIUM,
SubscriptionType.MOBILE_ONLY -> true
else -> false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum class SubscriptionType(
val isProjectInfoAvailable: Boolean = true,
val isCertificateAvailable: Boolean = true,
val areHintsLimited: Boolean = false,
val canUpgradeToMobileOnly: Boolean = false,
val subscriptionLimitType: SubscriptionLimitType = SubscriptionLimitType.NONE
) {
@SerialName("personal")
Expand Down Expand Up @@ -39,12 +40,14 @@ enum class SubscriptionType(
isCertificateAvailable = false,
isProjectInfoAvailable = false,
areHintsLimited = true,
canUpgradeToMobileOnly = true,
subscriptionLimitType = SubscriptionLimitType.PROBLEMS
),
MOBILE_CONTENT_TRIAL(
isCertificateAvailable = false,
isProjectInfoAvailable = false,
areHintsLimited = true,
canUpgradeToMobileOnly = true,
subscriptionLimitType = SubscriptionLimitType.TOPICS
),

Expand Down

0 comments on commit 5aadab9

Please sign in to comment.