Fix bugs around showing 0 bytes for backup size.

This commit is contained in:
Cody Henthorne
2025-09-10 16:05:12 -04:00
committed by GitHub
parent c155b4e025
commit 148cf63a92
5 changed files with 13 additions and 8 deletions

View File

@@ -100,5 +100,11 @@ sealed interface BackupState {
/**
* An error occurred retrieving the network state
*/
data object Error : BackupState
data class Error(val localState: BackupState) : BackupState
fun isLikelyPaidTier(): Boolean {
return (this is WithTypeAndRenewalTime && this.messageBackupsType is MessageBackupsType.Paid) ||
(this is LocalStore && this.tier == MessageBackupTier.PAID) ||
(this is Error && this.localState.isLikelyPaidTier())
}
}

View File

@@ -121,7 +121,7 @@ class BackupStateObserver(
scope.launch(SignalDispatchers.IO) {
InternetConnectionObserver.observe().asFlow()
.collect {
if (backupState.value == BackupState.Error) {
if (backupState.value is BackupState.Error) {
requestBackupStateRefresh()
}
}
@@ -347,7 +347,7 @@ class BackupStateObserver(
getDatabaseBackupState()
} else {
Log.d(TAG, "[getStateOnError] Displaying error without database.")
BackupState.Error
BackupState.Error(getDatabaseBackupState())
}
}

View File

@@ -88,7 +88,7 @@ class BackupsSettingsFragment : ComposeFragment() {
onNavigationClick = { requireActivity().onNavigateUp() },
onBackupsRowClick = {
when (state.backupState) {
BackupState.Error, BackupState.NotAvailable -> Unit
is BackupState.Error, BackupState.NotAvailable -> Unit
BackupState.None -> {
checkoutLauncher.launch(null)
@@ -185,7 +185,7 @@ private fun BackupsSettingsContent(
OtherWaysToBackUpHeading()
}
BackupState.Error -> {
is BackupState.Error -> {
WaitingForNetworkRow(
onBackupsRowClick = onBackupsRowClick
)

View File

@@ -907,7 +907,7 @@ private fun LazyListScope.appendBackupDetailsItems(
}
}
if (state.backupState !is BackupState.ActiveFree) {
if (state.backupState.isLikelyPaidTier()) {
item {
val sizeText = if (state.backupMediaSize < 0L) {
stringResource(R.string.RemoteBackupsSettingsFragment__calculating)

View File

@@ -33,7 +33,6 @@ import org.thoughtcrime.securesms.backup.DeletionState
import org.thoughtcrime.securesms.backup.v2.ArchiveRestoreProgress
import org.thoughtcrime.securesms.backup.v2.ArchiveRestoreProgressState.RestoreStatus
import org.thoughtcrime.securesms.backup.v2.BackupRepository
import org.thoughtcrime.securesms.backup.v2.MessageBackupTier
import org.thoughtcrime.securesms.components.settings.app.backups.BackupStateObserver
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository
import org.thoughtcrime.securesms.database.InAppPaymentTable
@@ -321,7 +320,7 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
}
private fun getBackupMediaSize(): Long {
return if (SignalStore.backup.backupTier == MessageBackupTier.PAID && SignalStore.backup.hasBackupBeenUploaded) {
return if (SignalStore.backup.hasBackupBeenUploaded || SignalStore.backup.lastBackupTime > 0L) {
SignalDatabase.attachments.getEstimatedArchiveMediaSize()
} else {
0L