mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Add proper media ttl to restore screen.
This commit is contained in:
@@ -66,6 +66,7 @@ import org.thoughtcrime.securesms.util.DateUtils
|
||||
import org.thoughtcrime.securesms.util.PlayStoreUtil
|
||||
import org.thoughtcrime.securesms.util.viewModel
|
||||
import java.util.Locale
|
||||
import kotlin.time.Duration
|
||||
|
||||
/**
|
||||
* Restore backup from remote source.
|
||||
@@ -268,7 +269,7 @@ private fun BackupAvailableContent(
|
||||
modifier = Modifier.padding(bottom = 6.dp)
|
||||
)
|
||||
|
||||
getFeatures(state.backupTier).forEach {
|
||||
getFeatures(state.backupTier, state.backupMediaTTL).forEach {
|
||||
MessageBackupsTypeFeatureRow(
|
||||
messageBackupsTypeFeature = it,
|
||||
iconTint = MaterialTheme.colorScheme.primary,
|
||||
@@ -322,7 +323,7 @@ private fun RestoreFromBackupContentLoadingPreview() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getFeatures(tier: MessageBackupTier?): ImmutableList<MessageBackupsTypeFeature> {
|
||||
private fun getFeatures(tier: MessageBackupTier?, mediaTTL: Duration): ImmutableList<MessageBackupsTypeFeature> {
|
||||
return when (tier) {
|
||||
null -> persistentListOf()
|
||||
MessageBackupTier.PAID -> {
|
||||
@@ -342,7 +343,7 @@ private fun getFeatures(tier: MessageBackupTier?): ImmutableList<MessageBackupsT
|
||||
persistentListOf(
|
||||
MessageBackupsTypeFeature(
|
||||
iconResourceId = R.drawable.symbol_thread_compact_bold_16,
|
||||
label = stringResource(id = R.string.RemoteRestoreActivity__your_last_d_days_of_media, 30)
|
||||
label = stringResource(id = R.string.RemoteRestoreActivity__your_last_d_days_of_media, mediaTTL.inWholeDays)
|
||||
),
|
||||
MessageBackupsTypeFeature(
|
||||
iconResourceId = R.drawable.symbol_recent_compact_bold_16,
|
||||
|
||||
@@ -32,6 +32,8 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.keyvalue.Skipped
|
||||
import org.thoughtcrime.securesms.registrationv3.data.QuickRegistrationRepository
|
||||
import org.whispersystems.signalservice.api.provisioning.RestoreMethod
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
class RemoteRestoreViewModel(isOnlyRestoreOption: Boolean) : ViewModel() {
|
||||
|
||||
@@ -77,6 +79,15 @@ class RemoteRestoreViewModel(isOnlyRestoreOption: Boolean) : ViewModel() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val config = BackupRepository.getBackupLevelConfiguration()
|
||||
if (config != null) {
|
||||
store.update {
|
||||
it.copy(backupMediaTTL = config.mediaTtlDays.days)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun restore() {
|
||||
@@ -161,6 +172,7 @@ class RemoteRestoreViewModel(isOnlyRestoreOption: Boolean) : ViewModel() {
|
||||
|
||||
data class ScreenState(
|
||||
val isRemoteRestoreOnlyOption: Boolean = false,
|
||||
val backupMediaTTL: Duration = 30.days,
|
||||
val backupTier: MessageBackupTier? = null,
|
||||
val backupTime: Long = -1,
|
||||
val backupSize: ByteSize = 0.bytes,
|
||||
|
||||
Reference in New Issue
Block a user