Update restore progress banner UI/UX and job behavior.

This commit is contained in:
Cody Henthorne
2024-10-02 09:49:28 -04:00
committed by Greyson Parrelli
parent 320d51707d
commit 93609106b0
20 changed files with 491 additions and 229 deletions

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.keyvalue
import com.fasterxml.jackson.annotation.JsonProperty
import kotlinx.coroutines.flow.Flow
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.backup.RestoreState
import org.thoughtcrime.securesms.backup.v2.BackupFrequency
@@ -65,7 +66,6 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
var nextBackupTime: Long by longValue(KEY_NEXT_BACKUP_TIME, -1)
var lastBackupTime: Long by longValue(KEY_LAST_BACKUP_TIME, -1)
var lastMediaSyncTime: Long by longValue(KEY_LAST_BACKUP_MEDIA_SYNC_TIME, -1)
var totalRestorableAttachmentSize: Long by longValue(KEY_TOTAL_RESTORABLE_ATTACHMENT_SIZE, 0)
var backupFrequency: BackupFrequency by enumValue(KEY_BACKUP_FREQUENCY, BackupFrequency.MANUAL, BackupFrequency.Serializer)
var backupTier: MessageBackupTier? by enumValue(KEY_BACKUP_TIER, null, MessageBackupTier.Serializer)
@@ -96,6 +96,11 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
var backupsInitialized: Boolean by booleanValue(KEY_BACKUPS_INITIALIZED, false)
private val totalRestorableAttachmentSizeValue = longValue(KEY_TOTAL_RESTORABLE_ATTACHMENT_SIZE, 0)
var totalRestorableAttachmentSize: Long by totalRestorableAttachmentSizeValue
val totalRestorableAttachmentSizeFlow: Flow<Long>
get() = totalRestorableAttachmentSizeValue.toFlow()
val isRestoreInProgress: Boolean
get() = totalRestorableAttachmentSize > 0

View File

@@ -1,6 +1,8 @@
package org.thoughtcrime.securesms.keyvalue
import com.squareup.wire.ProtoAdapter
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import org.signal.core.util.LongSerializer
import kotlin.reflect.KProperty
@@ -45,12 +47,22 @@ internal fun <M> SignalStoreValues.protoValue(key: String, adapter: ProtoAdapter
* class to callers and protect the individual implementations as private behind the various extension functions.
*/
sealed class SignalStoreValueDelegate<T>(private val store: KeyValueStore) {
private var flow: Lazy<MutableStateFlow<T>> = lazy { MutableStateFlow(getValue(store)) }
operator fun getValue(thisRef: Any?, property: KProperty<*>): T {
return getValue(store)
}
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
setValue(store, value)
if (flow.isInitialized()) {
flow.value.tryEmit(value)
}
}
fun toFlow(): Flow<T> {
return flow.value
}
internal abstract fun getValue(values: KeyValueStore): T