Performance: Avoids saving the first collection on login
This commit is contained in:
@@ -122,13 +122,13 @@ class AccountSettings(
|
|||||||
var hasDonatedInVersion: MutableStateFlow<Set<String>> = MutableStateFlow(setOf<String>()),
|
var hasDonatedInVersion: MutableStateFlow<Set<String>> = MutableStateFlow(setOf<String>()),
|
||||||
val pendingAttestations: MutableStateFlow<Map<HexKey, String>> = MutableStateFlow<Map<HexKey, String>>(mapOf()),
|
val pendingAttestations: MutableStateFlow<Map<HexKey, String>> = MutableStateFlow<Map<HexKey, String>>(mapOf()),
|
||||||
) {
|
) {
|
||||||
val saveable = MutableStateFlow(AccountSettingsUpdater(this))
|
val saveable = MutableStateFlow(AccountSettingsUpdater(null))
|
||||||
val syncedSettings: AccountSyncedSettings =
|
val syncedSettings: AccountSyncedSettings =
|
||||||
backupSyncedSettings?.let { AccountSyncedSettings(it) }
|
backupSyncedSettings?.let { AccountSyncedSettings(it) }
|
||||||
?: AccountSyncedSettings(AccountSyncedSettingsInternal())
|
?: AccountSyncedSettings(AccountSyncedSettingsInternal())
|
||||||
|
|
||||||
class AccountSettingsUpdater(
|
class AccountSettingsUpdater(
|
||||||
val accountSettings: AccountSettings,
|
val accountSettings: AccountSettings?,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun saveAccountSettings() {
|
fun saveAccountSettings() {
|
||||||
|
|||||||
@@ -179,10 +179,12 @@ class AccountStateViewModel : ViewModel() {
|
|||||||
collectorJob =
|
collectorJob =
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
accountSettings.saveable.debounce(1000).collect {
|
accountSettings.saveable.debounce(1000).collect {
|
||||||
|
if (it.accountSettings != null) {
|
||||||
LocalPreferences.saveToEncryptedStorage(it.accountSettings)
|
LocalPreferences.saveToEncryptedStorage(it.accountSettings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun prepareLogoutOrSwitch() =
|
private fun prepareLogoutOrSwitch() =
|
||||||
when (val state = _accountContent.value) {
|
when (val state = _accountContent.value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user