From 5fff0a2923487639924eba0defa86409af5f559c Mon Sep 17 00:00:00 2001 From: Benjamin <73490201+BenjaminHalko@users.noreply.github.com> Date: Thu, 2 Nov 2023 08:46:53 -0700 Subject: [PATCH] fix: option state crash (#1456) Co-authored-by: Ax333l --- .../manager/ui/viewmodel/SelectedAppInfoViewModel.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/revanced/manager/ui/viewmodel/SelectedAppInfoViewModel.kt b/app/src/main/java/app/revanced/manager/ui/viewmodel/SelectedAppInfoViewModel.kt index 4ab02aaa..86fca7de 100644 --- a/app/src/main/java/app/revanced/manager/ui/viewmodel/SelectedAppInfoViewModel.kt +++ b/app/src/main/java/app/revanced/manager/ui/viewmodel/SelectedAppInfoViewModel.kt @@ -59,10 +59,11 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent { var options: Options by savedStateHandle.saveable { val state = mutableStateOf(emptyMap()) - viewModelScope.launch(Dispatchers.Default) { + viewModelScope.launch { 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