mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix bugs around showing 0 bytes for backup size.
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user