Skip to content

Commit

Permalink
Hide inactive plan details on subscription screen
Browse files Browse the repository at this point in the history
  • Loading branch information
chRyNaN committed Feb 23, 2025
1 parent f53a8d1 commit b976f07
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.mooncloak.vpn.app.shared.api.billing.ServicePurchaseReceiptRepository
import com.mooncloak.vpn.app.shared.api.plan.ServicePlansRepository
import com.mooncloak.vpn.app.shared.api.service.ServiceSubscription
import com.mooncloak.vpn.app.shared.api.service.ServiceSubscriptionUsage
import com.mooncloak.vpn.app.shared.api.service.isActive
import com.mooncloak.vpn.app.shared.api.token.Token
import com.mooncloak.vpn.app.shared.di.FeatureScoped
import com.mooncloak.vpn.app.shared.feature.subscription.model.SubscriptionDetails
Expand Down Expand Up @@ -94,7 +95,7 @@ public class SubscriptionViewModel @Inject public constructor(
usage: ServiceSubscriptionUsage? = null
) {
try {
if (subscription != null) {
if (subscription != null && subscription.isActive(clock.now())) {
val purchased = dateTimeFormatter.format(subscription.created)
val expiration = dateTimeFormatter.format(subscription.expiration)
val totalData = (subscription.totalThroughput)?.let { bytes ->
Expand Down Expand Up @@ -126,6 +127,10 @@ public class SubscriptionViewModel @Inject public constructor(
)
)
}
} else {
emit { current ->
current.copy(details = null)
}
}
} catch (e: Exception) {
LogPile.error(
Expand Down

0 comments on commit b976f07

Please sign in to comment.