@@ -36,7 +36,6 @@ import app.morphe.manager.ui.viewmodel.PatchOptionsViewModel
3636import app.morphe.manager.util.KnownApps
3737import app.morphe.manager.util.toast
3838import kotlinx.coroutines.launch
39- import org.koin.androidx.compose.koinViewModel
4039
4140/* *
4241 * Advanced patch options section.
@@ -46,8 +45,8 @@ import org.koin.androidx.compose.koinViewModel
4645@Composable
4746fun PatchOptionsSection (
4847 patchOptionsPrefs : PatchOptionsPreferencesManager ,
49- patchOptionsViewModel : PatchOptionsViewModel = koinViewModel() ,
50- homeViewModel : HomeViewModel = koinViewModel()
48+ patchOptionsViewModel : PatchOptionsViewModel ,
49+ homeViewModel : HomeViewModel
5150) {
5251 val scope = rememberCoroutineScope()
5352 val context = LocalContext .current
@@ -69,8 +68,14 @@ fun PatchOptionsSection(
6968 val bundleInfo by homeViewModel.patchBundleRepository.bundleInfoFlow
7069 .collectAsStateWithLifecycle(emptyMap())
7170
71+ // Refresh only once when bundle info first becomes available.
72+ // Using a flag avoids re-triggering refresh on every recomposition or tab switch
73+ var hasRefreshed by remember { mutableStateOf(false ) }
7274 LaunchedEffect (bundleInfo) {
73- if (bundleInfo.isNotEmpty()) patchOptionsViewModel.refresh()
75+ if (bundleInfo.isNotEmpty() && ! hasRefreshed) {
76+ hasRefreshed = true
77+ patchOptionsViewModel.refresh()
78+ }
7479 }
7580
7681 val noPatchesAvailable = patchOptionsViewModel.noPatchesAvailable
0 commit comments