Standardize internal UI state property naming.

This commit is contained in:
Jeffrey Starke
2025-10-22 09:45:49 -04:00
committed by Greyson Parrelli
parent d4c266561f
commit e235ce52e5
9 changed files with 82 additions and 83 deletions

View File

@@ -18,8 +18,8 @@ class AccountSettingsViewModel : ViewModel() {
}
fun togglePinKeyboardType() {
store.update { previousState ->
previousState.copy(pinKeyboardType = previousState.pinKeyboardType.other)
store.update {
it.copy(pinKeyboardType = it.pinKeyboardType.other)
}
}

View File

@@ -22,22 +22,22 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.whispersystems.signalservice.api.AccountEntropyPool
class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler {
private val _uiState = MutableStateFlow(BackupKeyDisplayUiState())
val uiState: StateFlow<BackupKeyDisplayUiState> = _uiState.asStateFlow()
private val internalUiState = MutableStateFlow(BackupKeyDisplayUiState())
val uiState: StateFlow<BackupKeyDisplayUiState> = internalUiState.asStateFlow()
override fun updateBackupKeySaveState(newState: BackupKeySaveState?) {
_uiState.update { it.copy(keySaveState = newState) }
internalUiState.update { it.copy(keySaveState = newState) }
}
fun rotateBackupKey() {
viewModelScope.launch {
_uiState.update { it.copy(rotationState = BackupKeyRotationState.GENERATING_KEY) }
internalUiState.update { it.copy(rotationState = BackupKeyRotationState.GENERATING_KEY) }
val stagedKeyRotations = withContext(SignalDispatchers.IO) {
BackupRepository.stageBackupKeyRotations()
}
_uiState.update {
internalUiState.update {
it.copy(
accountEntropyPool = stagedKeyRotations.aep,
stagedKeyRotations = stagedKeyRotations,
@@ -49,15 +49,15 @@ class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler
fun commitBackupKey() {
viewModelScope.launch {
_uiState.update { it.copy(rotationState = BackupKeyRotationState.COMMITTING_KEY) }
internalUiState.update { it.copy(rotationState = BackupKeyRotationState.COMMITTING_KEY) }
val keyRotations = _uiState.value.stagedKeyRotations ?: error("No key rotations to commit!")
val keyRotations = internalUiState.value.stagedKeyRotations ?: error("No key rotations to commit!")
withContext(SignalDispatchers.IO) {
BackupRepository.commitAEPKeyRotation(keyRotations)
}
_uiState.update { it.copy(rotationState = BackupKeyRotationState.FINISHED) }
internalUiState.update { it.copy(rotationState = BackupKeyRotationState.FINISHED) }
}
}

View File

@@ -151,8 +151,8 @@ class ChangeNumberViewModel : ViewModel() {
}
fun togglePinKeyboardType() {
store.update { previousState ->
previousState.copy(pinKeyboardType = previousState.pinKeyboardType.other)
store.update {
it.copy(pinKeyboardType = it.pinKeyboardType.other)
}
}
@@ -442,6 +442,7 @@ class ChangeNumberViewModel : ViewModel() {
svr3Credentials = result.svr3Credentials
)
}
else -> Log.i(TAG, "Received exception during verification.", result.getCause())
}
@@ -459,6 +460,7 @@ class ChangeNumberViewModel : ViewModel() {
svr3Credentials = result.svr3Credentials
)
}
is ChangeNumberResult.SvrWrongPin -> {
store.update {
it.copy(
@@ -466,6 +468,7 @@ class ChangeNumberViewModel : ViewModel() {
)
}
}
else -> Log.i(TAG, "Received exception during change number.", result.getCause())
}