Remove hard coded message backups remote config.

This commit is contained in:
Cody Henthorne
2025-09-22 16:38:01 -04:00
committed by Jeffrey Starke
parent 6976ac7d44
commit 8b2f58e0e7
31 changed files with 58 additions and 220 deletions

View File

@@ -371,7 +371,7 @@ private fun AppSettingsContent(
onClick = {
callbacks.navigate(AppSettingsRoute.ChatsRoute.Chats)
},
enabled = state.legacyLocalBackupsEnabled || isRegisteredAndUpToDate
enabled = isRegisteredAndUpToDate
)
}
@@ -408,31 +408,29 @@ private fun AppSettingsContent(
)
}
if (state.showBackups) {
item {
Rows.TextRow(
text = {
TextWithBetaLabel(
text = stringResource(R.string.preferences_chats__backups),
textStyle = MaterialTheme.typography.bodyLarge
)
},
icon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.symbol_backup_24),
contentDescription = stringResource(R.string.preferences_chats__backups),
tint = MaterialTheme.colorScheme.onSurface
)
},
onClick = {
callbacks.navigate(AppSettingsRoute.BackupsRoute.Backups)
},
onLongClick = {
callbacks.copyRemoteBackupsSubscriberIdToClipboard()
},
enabled = isRegisteredAndUpToDate
)
}
item {
Rows.TextRow(
text = {
TextWithBetaLabel(
text = stringResource(R.string.preferences_chats__backups),
textStyle = MaterialTheme.typography.bodyLarge
)
},
icon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.symbol_backup_24),
contentDescription = stringResource(R.string.preferences_chats__backups),
tint = MaterialTheme.colorScheme.onSurface
)
},
onClick = {
callbacks.navigate(AppSettingsRoute.BackupsRoute.Backups)
},
onLongClick = {
callbacks.copyRemoteBackupsSubscriberIdToClipboard()
},
enabled = isRegisteredAndUpToDate
)
}
item {
@@ -702,9 +700,7 @@ private fun AppSettingsContentPreview() {
showInternalPreferences = true,
showPayments = true,
showAppUpdates = true,
showBackups = true,
backupFailureState = BackupFailureState.OUT_OF_STORAGE_SPACE,
legacyLocalBackupsEnabled = false
backupFailureState = BackupFailureState.OUT_OF_STORAGE_SPACE
),
bannerManager = BannerManager(
banners = listOf(TestBanner())

View File

@@ -15,9 +15,7 @@ data class AppSettingsState(
val showInternalPreferences: Boolean = RemoteConfig.internalUser,
val showPayments: Boolean = SignalStore.payments.paymentsAvailability.showPaymentsMenu(),
val showAppUpdates: Boolean = Environment.IS_NIGHTLY,
val showBackups: Boolean = RemoteConfig.messageBackups,
val backupFailureState: BackupFailureState = BackupFailureState.NONE,
val legacyLocalBackupsEnabled: Boolean
val backupFailureState: BackupFailureState = BackupFailureState.NONE
) {
fun isRegisteredAndUpToDate(): Boolean {
return !userUnregistered && !clientDeprecated

View File

@@ -14,8 +14,6 @@ import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.BackupUtil
import org.thoughtcrime.securesms.util.RemoteConfig
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.thoughtcrime.securesms.util.livedata.Store
@@ -27,8 +25,7 @@ class AppSettingsViewModel : ViewModel() {
hasExpiredGiftBadge = SignalStore.inAppPayments.getExpiredGiftBadge() != null,
allowUserToGoToDonationManagementScreen = SignalStore.inAppPayments.isLikelyASustainer() || InAppDonations.hasAtLeastOnePaymentMethodAvailable(),
userUnregistered = TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account.isRegistered,
clientDeprecated = SignalStore.misc.isClientDeprecated,
legacyLocalBackupsEnabled = !RemoteConfig.messageBackups && SignalStore.settings.isBackupEnabled && BackupUtil.canUserAccessBackupDirectory(AppDependencies.application)
clientDeprecated = SignalStore.misc.isClientDeprecated
)
)
@@ -74,9 +71,7 @@ class AppSettingsViewModel : ViewModel() {
}
private fun getBackupFailureState(): BackupFailureState {
return if (!RemoteConfig.messageBackups) {
BackupFailureState.NONE
} else if (BackupRepository.shouldDisplayOutOfRemoteStorageSpaceUx()) {
return if (BackupRepository.shouldDisplayOutOfRemoteStorageSpaceUx()) {
BackupFailureState.OUT_OF_STORAGE_SPACE
} else if (BackupRepository.shouldDisplayBackupFailedSettingsRow()) {
BackupFailureState.BACKUP_FAILED

View File

@@ -15,11 +15,6 @@ import kotlin.time.Duration.Companion.seconds
* Describes the state of the user's selected backup tier.
*/
sealed interface BackupState {
/**
* Backups are not available on this device
*/
data object NotAvailable : BackupState
/**
* User has no active backup tier, no tier history
*/

View File

@@ -33,7 +33,6 @@ import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.InternetConnectionObserver
import org.thoughtcrime.securesms.util.RemoteConfig
import org.whispersystems.signalservice.api.NetworkResult
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription
import java.math.BigDecimal
@@ -80,16 +79,12 @@ class BackupStateObserver(
* setting initial ViewModel state values.
*/
fun getNonIOBackupState(): BackupState {
return if (RemoteConfig.messageBackups) {
val tier = SignalStore.backup.backupTier
val tier = SignalStore.backup.backupTier
if (tier != null) {
BackupState.LocalStore(tier)
} else {
BackupState.None
}
return if (tier != null) {
BackupState.LocalStore(tier)
} else {
BackupState.NotAvailable
BackupState.None
}
}
}
@@ -217,11 +212,6 @@ class BackupStateObserver(
}
private suspend fun performDatabaseBackupStateRefresh() {
if (!RemoteConfig.messageBackups) {
Log.d(TAG, "[performDatabaseBackupStateRefresh] Dropping refresh for disabled feature.")
return
}
if (!SignalStore.account.isRegistered) {
Log.d(TAG, "[performDatabaseBackupStateRefresh] Dropping refresh for unregistered user.")
return
@@ -236,11 +226,6 @@ class BackupStateObserver(
}
private suspend fun performFullBackupStateRefresh() {
if (!RemoteConfig.messageBackups) {
Log.d(TAG, "[performFullBackupStateRefresh] Dropping refresh for disabled feature.")
return
}
if (!SignalStore.account.isRegistered) {
Log.d(TAG, "[performFullBackupStateRefresh] Dropping refresh for unregistered user.")
return

View File

@@ -92,7 +92,7 @@ class BackupsSettingsFragment : ComposeFragment() {
onNavigationClick = { requireActivity().onNavigateUp() },
onBackupsRowClick = {
when (state.backupState) {
is BackupState.Error, BackupState.NotAvailable -> Unit
is BackupState.Error -> Unit
BackupState.None -> {
checkoutLauncher.launch(null)
@@ -197,8 +197,6 @@ private fun BackupsSettingsContent(
OtherWaysToBackUpHeading()
}
BackupState.NotAvailable -> Unit
BackupState.NotFound -> {
NotFoundBackupRow(
onBackupsRowClick = onBackupsRowClick
@@ -630,19 +628,6 @@ private fun BackupsSettingsContentPreview() {
}
}
@SignalPreview
@Composable
private fun BackupsSettingsContentNotAvailablePreview() {
Previews.Preview {
BackupsSettingsContent(
backupsSettingsState = BackupsSettingsState(
backupState = BackupState.NotAvailable,
lastBackupAt = 0.seconds
)
)
}
}
@SignalPreview
@Composable
private fun BackupsSettingsContentBackupTierInternalOverridePreview() {

View File

@@ -519,8 +519,6 @@ private fun RemoteBackupsSettingsContent(
isRenewEnabled = backupDeleteState.isIdle()
)
}
BackupState.NotAvailable -> error("This shouldn't happen on this screen.")
}
}

View File

@@ -22,7 +22,6 @@ import org.signal.core.ui.compose.Texts
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.compose.ComposeFragment
import org.thoughtcrime.securesms.compose.rememberStatusBarColorNestedScrollModifier
import org.thoughtcrime.securesms.util.RemoteConfig
import org.thoughtcrime.securesms.util.navigation.safeNavigate
/**
@@ -45,8 +44,7 @@ class ChatsSettingsFragment : ComposeFragment() {
ChatsSettingsScreen(
state = state,
callbacks = callbacks,
isRemoteBackupsAvailable = RemoteConfig.messageBackups
callbacks = callbacks
)
}
@@ -105,7 +103,6 @@ private interface ChatsSettingsCallbacks {
@Composable
private fun ChatsSettingsScreen(
isRemoteBackupsAvailable: Boolean,
state: ChatsSettingsState,
callbacks: ChatsSettingsCallbacks
) {
@@ -201,25 +198,6 @@ private fun ChatsSettingsScreen(
onCheckChanged = callbacks::onEnterKeySendsChanged
)
}
if (!isRemoteBackupsAvailable) {
item {
Dividers.Default()
}
item {
Texts.SectionHeader(stringResource(R.string.preferences_chats__backups))
}
item {
Rows.TextRow(
text = stringResource(R.string.preferences_chats__chat_backups),
label = stringResource(if (state.localBackupsEnabled) R.string.arrays__enabled else R.string.arrays__disabled),
enabled = state.localBackupsEnabled || state.isRegisteredAndUpToDate(),
onClick = callbacks::onChatBackupsClick
)
}
}
}
}
}
@@ -240,8 +218,7 @@ private fun ChatsSettingsScreenPreview() {
userUnregistered = false,
clientDeprecated = false
),
callbacks = ChatsSettingsCallbacks.Empty,
isRemoteBackupsAvailable = false
callbacks = ChatsSettingsCallbacks.Empty
)
}
}

View File

@@ -42,18 +42,16 @@ class ManageStorageSettingsViewModel : ViewModel() {
val state = store.asStateFlow()
init {
if (RemoteConfig.messageBackups) {
viewModelScope.launch(Dispatchers.IO) {
InAppPaymentsRepository.observeLatestBackupPayment()
.collectLatest { payment ->
store.update { it.copy(isPaidTierPending = payment.state == InAppPaymentTable.State.PENDING) }
}
}
viewModelScope.launch {
store.update {
it.copy(onDeviceStorageOptimizationState = getOnDeviceStorageOptimizationState())
viewModelScope.launch(Dispatchers.IO) {
InAppPaymentsRepository.observeLatestBackupPayment()
.collectLatest { payment ->
store.update { it.copy(isPaidTierPending = payment.state == InAppPaymentTable.State.PENDING) }
}
}
viewModelScope.launch {
store.update {
it.copy(onDeviceStorageOptimizationState = getOnDeviceStorageOptimizationState())
}
}
}
@@ -135,7 +133,7 @@ class ManageStorageSettingsViewModel : ViewModel() {
private suspend fun getOnDeviceStorageOptimizationState(): OnDeviceStorageOptimizationState {
return when {
!RemoteConfig.messageBackups || !SignalStore.backup.areBackupsEnabled || !AppDependencies.billingApi.getApiAvailability().isSuccess || (!RemoteConfig.internalUser && !Environment.IS_STAGING) -> OnDeviceStorageOptimizationState.FEATURE_NOT_AVAILABLE
!SignalStore.backup.areBackupsEnabled || !AppDependencies.billingApi.getApiAvailability().isSuccess || (!RemoteConfig.internalUser && !Environment.IS_STAGING) -> OnDeviceStorageOptimizationState.FEATURE_NOT_AVAILABLE
SignalStore.backup.backupTier != MessageBackupTier.PAID -> OnDeviceStorageOptimizationState.REQUIRES_PAID_TIER
SignalStore.backup.optimizeStorage -> OnDeviceStorageOptimizationState.ENABLED
else -> OnDeviceStorageOptimizationState.DISABLED

View File

@@ -26,7 +26,6 @@ import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.database.model.databaseprotos.DonationErrorValue
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.util.RemoteConfig
/**
* Handles displaying bottom sheets for in-app payments. The current policy is to "fire and forget".
@@ -58,10 +57,7 @@ class InAppPaymentsBottomSheetDelegate(
handleLegacyTerminalDonationSheets()
handleLegacyVerifiedMonthlyDonationSheets()
handleInAppPaymentDonationSheets()
if (RemoteConfig.messageBackups) {
handleInAppPaymentBackupsSheets()
}
handleInAppPaymentBackupsSheets()
}
/**