diff --git a/app/src/main/java/app/revanced/manager/ui/screen/SelectedAppInfoScreen.kt b/app/src/main/java/app/revanced/manager/ui/screen/SelectedAppInfoScreen.kt index 2d50e62c6e..230edc7bbb 100644 --- a/app/src/main/java/app/revanced/manager/ui/screen/SelectedAppInfoScreen.kt +++ b/app/src/main/java/app/revanced/manager/ui/screen/SelectedAppInfoScreen.kt @@ -107,7 +107,7 @@ fun SelectedAppInfoScreen( is SelectedAppInfoDestination.VersionSelector -> VersionSelectorScreen( onBackClick = navController::pop, onAppClick = { - vm.setSelectedApp(it) + vm.selectedApp = it navController.pop() }, viewModel = getViewModel { parametersOf(vm.selectedApp.packageName) } 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 e66ec07473..c3d9d09356 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 @@ -35,13 +35,18 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent { private val savedStateHandle: SavedStateHandle = get() val prefs: PreferencesManager = get() - var selectedApp by savedStateHandle.saveable { + private var _selectedApp by savedStateHandle.saveable { mutableStateOf(input.app) } - private set + + var selectedApp + get() = _selectedApp + set(value) { + invalidateSelectedAppInfo() + _selectedApp = value + } var selectedAppInfo: PackageInfo? by mutableStateOf(null) - private set init { invalidateSelectedAppInfo() @@ -72,11 +77,6 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent { selection } - fun setSelectedApp(new: SelectedApp) { - selectedApp = new - invalidateSelectedAppInfo() - } - private fun invalidateSelectedAppInfo() = viewModelScope.launch { val info = when (val app = selectedApp) { is SelectedApp.Download -> null