mirror of
https://github.com/bitwarden/android.git
synced 2026-06-04 19:56:39 -05:00
BIT-1729: Re-load the options to apply policy values (#1000)
This commit is contained in:
committed by
Álison Fernandes
parent
6bfb9440b5
commit
5928987a9b
@@ -101,10 +101,7 @@ class GeneratorViewModel @Inject constructor(
|
||||
|
||||
init {
|
||||
stateFlow.onEach { savedStateHandle[KEY_STATE] = it }.launchIn(viewModelScope)
|
||||
when (val selectedType = mutableStateFlow.value.selectedType) {
|
||||
is Passcode -> loadPasscodeOptions(selectedType, usePolicyDefault = true)
|
||||
is Username -> loadUsernameOptions(selectedType)
|
||||
}
|
||||
loadOptions()
|
||||
policyManager
|
||||
.getActivePoliciesFlow<PolicyInformation.PasswordGenerator>()
|
||||
.map { GeneratorAction.Internal.PasswordGeneratorPolicyReceive(it) }
|
||||
@@ -251,6 +248,13 @@ class GeneratorViewModel @Inject constructor(
|
||||
|
||||
//region Generation Handlers
|
||||
|
||||
private fun loadOptions() {
|
||||
when (val selectedType = state.selectedType) {
|
||||
is Passcode -> loadPasscodeOptions(selectedType = selectedType, usePolicyDefault = true)
|
||||
is Username -> loadUsernameOptions(selectedType = selectedType)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("CyclomaticComplexMethod")
|
||||
private fun loadPasscodeOptions(selectedType: Passcode, usePolicyDefault: Boolean) {
|
||||
val passwordType = if (usePolicyDefault) {
|
||||
@@ -652,6 +656,7 @@ class GeneratorViewModel @Inject constructor(
|
||||
action: GeneratorAction.Internal.PasswordGeneratorPolicyReceive,
|
||||
) {
|
||||
mutableStateFlow.update { it.copy(isUnderPolicy = action.policies.any()) }
|
||||
loadOptions()
|
||||
}
|
||||
|
||||
//endregion Generated Field Handlers
|
||||
|
||||
Reference in New Issue
Block a user