Neal Sanche
10/28/2021, 9:40 PMIan Lake
10/28/2021, 10:22 PMNeal Sanche
10/28/2021, 10:41 PMinit {
println(savedStateHandle.keys())
savedStateHandle.remove<String>("code")?.let { code ->
// If we get here, we've probably been given a deep link with the code
// to verify. We only want to do this once, so we remove the code from the
// saved state.
viewModelScope.launch {
if (!(sharedPreferences.getStringSet(CODES_KEY, null)
?: setOf()).contains(code)
) {
onVerifyCode(code)
} else {
println("Already succeeded code, skipping.")
}
}
}
savedStateHandle.get<String>("state")?.let { state ->
// The state contains the bank id, which we will look up and add to the viewState
val bankId = state.substringAfter("openid id:")
loadBank(bankId)
}
}
Ian Lake
10/28/2021, 10:50 PMSavedStateHandle
- when it is recreated, it unconditionally adds all of the default arguments (i.e., those passed to your destination), then adds each value from the saved statestate.put("processed", true)
, that would come back after process death, but your remove
gets 'undone' as it was by that default valueremove
call "sticks"SavedStateHandle
issue? https://issuetracker.google.com/issues/new?component=413132&template=1096619Neal Sanche
10/29/2021, 3:11 PMSavedStateHandle
worked, and allowed me to remove my other workaround. Thanks again Ian.