Wire in NetworkResult for Types.

This commit is contained in:
Alex Hart
2025-07-11 10:27:52 -03:00
committed by Jeffrey Starke
parent 7753aadbf0
commit b45fb28dbe
3 changed files with 24 additions and 22 deletions

View File

@@ -1611,20 +1611,18 @@ object BackupRepository {
}
suspend fun getAvailableBackupsTypes(availableBackupTiers: List<MessageBackupTier>): List<MessageBackupsType> {
return availableBackupTiers.mapNotNull { getBackupsType(it) }
return availableBackupTiers.mapNotNull {
val type = getBackupsType(it)
if (type is NetworkResult.Success) type.result else null
}
}
suspend fun getBackupsType(tier: MessageBackupTier): MessageBackupsType? {
val result = when (tier) {
private suspend fun getBackupsType(tier: MessageBackupTier): NetworkResult<out MessageBackupsType> {
return when (tier) {
MessageBackupTier.FREE -> getFreeType()
MessageBackupTier.PAID -> getPaidType()
}
return if (result is NetworkResult.Success) {
result.result
} else {
null
}
}
@WorkerThread
@@ -1642,7 +1640,7 @@ object BackupRepository {
}
@WorkerThread
private fun getFreeType(): NetworkResult<MessageBackupsType.Free> {
fun getFreeType(): NetworkResult<MessageBackupsType.Free> {
return AppDependencies.donationsApi
.getDonationsConfiguration(Locale.getDefault())
.map {