From 778fd01557fc65471a16e03f0f1c1dd1729fa628 Mon Sep 17 00:00:00 2001 From: Aleksandar Ilic Date: Tue, 12 Nov 2024 23:22:48 +0100 Subject: [PATCH] Update to latest membership status response --- .../premium/api/model/MembershipStatusResponse.kt | 2 +- .../primal/android/premium/domain/PremiumMembership.kt | 4 ++-- .../primal/android/premium/ui/PrimalPremiumTable.kt | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/net/primal/android/premium/api/model/MembershipStatusResponse.kt b/app/src/main/kotlin/net/primal/android/premium/api/model/MembershipStatusResponse.kt index 4870eca40..ddc2dd2d2 100644 --- a/app/src/main/kotlin/net/primal/android/premium/api/model/MembershipStatusResponse.kt +++ b/app/src/main/kotlin/net/primal/android/premium/api/model/MembershipStatusResponse.kt @@ -13,9 +13,9 @@ data class MembershipStatusResponse( @SerialName("primal_vip_profile") val primalVipProfile: String, @SerialName("used_storage") val usedStorage: Long, @SerialName("max_storage") val maxStorage: Long, - @SerialName("expires_on") val expiresOn: Long, @SerialName("cohort_1") val cohort1: String, @SerialName("cohort_2") val cohort2: String, + @SerialName("expires_on") val expiresOn: Long? = null, @SerialName("recurring") val recurring: Boolean = false, @SerialName("renews_on") val renewsOn: Long? = null, ) diff --git a/app/src/main/kotlin/net/primal/android/premium/domain/PremiumMembership.kt b/app/src/main/kotlin/net/primal/android/premium/domain/PremiumMembership.kt index 2d4067720..6ec2b0123 100644 --- a/app/src/main/kotlin/net/primal/android/premium/domain/PremiumMembership.kt +++ b/app/src/main/kotlin/net/primal/android/premium/domain/PremiumMembership.kt @@ -13,11 +13,11 @@ data class PremiumMembership( val vipProfile: String, val usedStorageInBytes: Long, val maxStorageInBytes: Long, - val expiresOn: Long, val cohort1: String, val cohort2: String, + val expiresOn: Long? = null, val recurring: Boolean = false, val renewsOn: Long? = null, ) { - fun isExpired() = Clock.System.now().epochSeconds > expiresOn + fun isExpired() = expiresOn != null && Clock.System.now().epochSeconds > expiresOn } diff --git a/app/src/main/kotlin/net/primal/android/premium/ui/PrimalPremiumTable.kt b/app/src/main/kotlin/net/primal/android/premium/ui/PrimalPremiumTable.kt index 58d19229e..ffd30b16f 100644 --- a/app/src/main/kotlin/net/primal/android/premium/ui/PrimalPremiumTable.kt +++ b/app/src/main/kotlin/net/primal/android/premium/ui/PrimalPremiumTable.kt @@ -75,11 +75,13 @@ fun PrimalPremiumTable( value = when { premiumMembership.recurring && premiumMembership.renewsOn != null -> Instant.ofEpochSecond(premiumMembership.renewsOn) + .formatToDefaultDateFormat(FormatStyle.LONG) - else -> - Instant.ofEpochSecond(premiumMembership.expiresOn) - } - .formatToDefaultDateFormat(FormatStyle.LONG), + premiumMembership.expiresOn != null -> Instant.ofEpochSecond(premiumMembership.expiresOn) + .formatToDefaultDateFormat(FormatStyle.LONG) + + else -> stringResource(R.string.premium_table_never) + }, alwaysHideApply = true, ) }