mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Do not connect to web socket until restore decision made.
This commit is contained in:
committed by
Greyson Parrelli
parent
d028fcff8b
commit
9c9620c917
@@ -408,7 +408,7 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
|
||||
putBoolean(KEY_IS_REGISTERED, registered)
|
||||
|
||||
AppDependencies.incomingMessageObserver.notifyRegistrationChanged()
|
||||
AppDependencies.incomingMessageObserver.notifyRegistrationStateChanged()
|
||||
|
||||
if (previous != registered) {
|
||||
Recipient.self().live().refresh()
|
||||
@@ -426,7 +426,7 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
|
||||
fun clearRegistrationButKeepCredentials() {
|
||||
putBoolean(KEY_IS_REGISTERED, false)
|
||||
|
||||
AppDependencies.incomingMessageObserver.notifyRegistrationChanged()
|
||||
AppDependencies.incomingMessageObserver.notifyRegistrationStateChanged()
|
||||
|
||||
Recipient.self().live().refresh()
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
val totalRestorableAttachmentSizeFlow: Flow<Long>
|
||||
get() = totalRestorableAttachmentSizeValue.toFlow()
|
||||
|
||||
val isRestoreInProgress: Boolean
|
||||
val isMediaRestoreInProgress: Boolean
|
||||
get() = totalRestorableAttachmentSize > 0
|
||||
|
||||
/** Store that lets you interact with message ZK credentials. */
|
||||
|
||||
@@ -4,6 +4,7 @@ import androidx.annotation.CheckResult
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.LocalRegistrationMetadata
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.RestoreDecisionState
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
|
||||
class RegistrationValues internal constructor(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
|
||||
@@ -71,5 +72,7 @@ class RegistrationValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
@get:JvmName("isRestoringOnNewDevice")
|
||||
var restoringOnNewDevice: Boolean by booleanValue(RESTORING_ON_NEW_DEVICE, false)
|
||||
|
||||
var restoreDecisionState: RestoreDecisionState by protoValue(RESTORE_DECISION_STATE, RestoreDecisionState.Skipped, RestoreDecisionState.ADAPTER)
|
||||
var restoreDecisionState: RestoreDecisionState by protoValue(RESTORE_DECISION_STATE, RestoreDecisionState.Skipped, RestoreDecisionState.ADAPTER) { newValue ->
|
||||
AppDependencies.incomingMessageObserver.notifyRegistrationStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ internal fun <M> SignalStoreValues.protoValue(key: String, adapter: ProtoAdapter
|
||||
return KeyValueProtoValue(key, adapter, this.store)
|
||||
}
|
||||
|
||||
internal fun <M> SignalStoreValues.protoValue(key: String, default: M, adapter: ProtoAdapter<M>): SignalStoreValueDelegate<M> {
|
||||
return KeyValueProtoWithDefaultValue(key, default, adapter, this.store)
|
||||
internal fun <M> SignalStoreValues.protoValue(key: String, default: M, adapter: ProtoAdapter<M>, onSet: ((M) -> Unit)? = null): SignalStoreValueDelegate<M> {
|
||||
return KeyValueProtoWithDefaultValue(key, default, adapter, this.store, onSet)
|
||||
}
|
||||
|
||||
internal fun <T> SignalStoreValueDelegate<T>.withPrecondition(precondition: () -> Boolean): SignalStoreValueDelegate<T> {
|
||||
@@ -64,7 +64,7 @@ internal fun <T> SignalStoreValueDelegate<T>.map(transform: (T) -> T): SignalSto
|
||||
* Kotlin delegate that serves as a base for all other value types. This allows us to only expose this sealed
|
||||
* class to callers and protect the individual implementations as private behind the various extension functions.
|
||||
*/
|
||||
sealed class SignalStoreValueDelegate<T>(val store: KeyValueStore, open val default: T) {
|
||||
sealed class SignalStoreValueDelegate<T>(val store: KeyValueStore, open val default: T, private val onSet: ((T) -> Unit)? = null) {
|
||||
|
||||
private var flow: Lazy<MutableStateFlow<T>> = lazy { MutableStateFlow(getValue(store)) }
|
||||
|
||||
@@ -74,6 +74,7 @@ sealed class SignalStoreValueDelegate<T>(val store: KeyValueStore, open val defa
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
||||
setValue(store, value)
|
||||
onSet?.invoke(value)
|
||||
if (flow.isInitialized()) {
|
||||
flow.value.tryEmit(value)
|
||||
}
|
||||
@@ -162,8 +163,9 @@ private class KeyValueProtoWithDefaultValue<M>(
|
||||
private val key: String,
|
||||
default: M,
|
||||
private val adapter: ProtoAdapter<M>,
|
||||
store: KeyValueStore
|
||||
) : SignalStoreValueDelegate<M>(store, default) {
|
||||
store: KeyValueStore,
|
||||
onSet: ((M) -> Unit)? = null
|
||||
) : SignalStoreValueDelegate<M>(store, default, onSet) {
|
||||
override fun getValue(values: KeyValueStore): M {
|
||||
return if (values.containsKey(key)) {
|
||||
adapter.decode(values.getBlob(key, null))
|
||||
|
||||
Reference in New Issue
Block a user