Skip to content

Commit

Permalink
fix: option state crash (#1456)
Browse files Browse the repository at this point in the history
Co-authored-by: Ax333l <main@axelen.xyz>
  • Loading branch information
BenjaminHalko and Axelen123 committed Nov 2, 2023
1 parent 8df7f29 commit 5fff0a2
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
var options: Options by savedStateHandle.saveable {
val state = mutableStateOf<Options>(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
Expand Down

0 comments on commit 5fff0a2

Please sign in to comment.