fix: option state crash (#1456)

Co-authored-by: Ax333l <main@axelen.xyz>
This commit is contained in:
Benjamin 2023-11-02 08:46:53 -07:00 committed by oSumAtrIX
parent 7a4b0bd7c8
commit 4b5e2e97f7
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -59,10 +59,11 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
var options: Options by savedStateHandle.saveable { var options: Options by savedStateHandle.saveable {
val state = mutableStateOf<Options>(emptyMap()) val state = mutableStateOf<Options>(emptyMap())
viewModelScope.launch(Dispatchers.Default) { viewModelScope.launch {
if (!persistConfiguration) return@launch // TODO: save options for patched apps. if (!persistConfiguration) return@launch // TODO: save options for patched apps.
state.value = optionsRepository.getOptions(selectedApp.packageName) val packageName = selectedApp.packageName // Accessing this from another thread may cause crashes.
state.value = withContext(Dispatchers.Default) { optionsRepository.getOptions(packageName) }
} }
state state