Add storage sync support for linked devices.

This commit is contained in:
Cody Henthorne
2022-01-21 16:19:17 -05:00
committed by Greyson Parrelli
parent 4f03c98f60
commit 22c396067d
15 changed files with 72 additions and 24 deletions

View File

@@ -103,13 +103,13 @@ class ExpireTimerSettingsFragment : DSLSettingsFragment(
val values: Array<Int> = resources.getIntArray(R.array.ExpireTimerSettingsFragment__values).toTypedArray()
var hasCustomValue = true
labels.zip(values).forEach { (label, value) ->
labels.zip(values).forEach { (label, seconds) ->
radioPref(
title = DSLSettingsText.from(label),
isChecked = state.currentTimer == value,
onClick = { viewModel.select(value) }
isChecked = state.currentTimer == seconds,
onClick = { viewModel.select(seconds) }
)
hasCustomValue = hasCustomValue && state.currentTimer != value
hasCustomValue = hasCustomValue && state.currentTimer != seconds
}
radioPref(

View File

@@ -8,10 +8,12 @@ import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.database.ThreadDatabase
import org.thoughtcrime.securesms.groups.GroupChangeException
import org.thoughtcrime.securesms.groups.GroupManager
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.sms.MessageSender
import org.thoughtcrime.securesms.storage.StorageSyncHelper
import java.io.IOException
private val TAG: String = Log.tag(ExpireTimerSettingsRepository::class.java)
@@ -44,6 +46,15 @@ class ExpireTimerSettingsRepository(val context: Context) {
}
}
fun setUniversalExpireTimerSeconds(newExpirationTime: Int, onDone: () -> Unit) {
SignalExecutors.BOUNDED.execute {
SignalStore.settings().universalExpireTimer = newExpirationTime
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
StorageSyncHelper.scheduleSyncForDataChange()
onDone.invoke()
}
}
@WorkerThread
private fun getThreadId(recipientId: RecipientId): Long {
val threadDatabase: ThreadDatabase = SignalDatabase.threads

View File

@@ -45,8 +45,9 @@ class ExpireTimerSettingsViewModel(val config: Config, private val repository: E
} else if (config.forResultMode) {
store.update { it.copy(saveState = ProcessState.Success(userSetTimer)) }
} else {
SignalStore.settings().universalExpireTimer = userSetTimer
store.update { it.copy(saveState = ProcessState.Success(userSetTimer)) }
repository.setUniversalExpireTimerSeconds(userSetTimer) {
store.update { it.copy(saveState = ProcessState.Success(userSetTimer)) }
}
}
}