Hide paid tier on devices where the billing API is not available.

This commit is contained in:
Alex Hart
2024-09-19 15:25:26 -03:00
committed by Greyson Parrelli
parent d88265ede6
commit d23ef647d8
2 changed files with 20 additions and 15 deletions

View File

@@ -883,10 +883,10 @@ object BackupRepository {
}
suspend fun getAvailableBackupsTypes(availableBackupTiers: List<MessageBackupTier>): List<MessageBackupsType> {
return availableBackupTiers.map { getBackupsType(it) }
return availableBackupTiers.mapNotNull { getBackupsType(it) }
}
suspend fun getBackupsType(tier: MessageBackupTier): MessageBackupsType {
suspend fun getBackupsType(tier: MessageBackupTier): MessageBackupsType? {
return when (tier) {
MessageBackupTier.FREE -> getFreeType()
MessageBackupTier.PAID -> getPaidType()
@@ -901,12 +901,12 @@ object BackupRepository {
)
}
private suspend fun getPaidType(): MessageBackupsType {
private suspend fun getPaidType(): MessageBackupsType? {
val config = getSubscriptionsConfiguration()
val product = AppDependencies.billingApi.queryProduct()
val product = AppDependencies.billingApi.queryProduct() ?: return null
return MessageBackupsType.Paid(
pricePerMonth = product!!.price,
pricePerMonth = product.price,
storageAllowanceBytes = config.backupConfiguration.backupLevelConfigurationMap[SubscriptionsConfiguration.BACKUPS_LEVEL]!!.storageAllowanceBytes
)
}