diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt index 2f689f65d068..0911885bf568 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt @@ -52,7 +52,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) { val viewModel = viewModel() LaunchedEffect(Unit) { - if (viewModel.moduleList.isEmpty()) { + if (viewModel.moduleList.isEmpty() || viewModel.isNeedRefresh) { viewModel.fetchModuleList() } } @@ -80,6 +80,8 @@ fun ModuleScreen(navigator: DestinationsNavigator) { navigator.navigate(InstallScreenDestination(uri)) + viewModel.markNeedRefresh() + Log.i("ModuleScreen", "select zip result: ${it.data}") } diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/ModuleViewModel.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/ModuleViewModel.kt index ca3331719d46..9be914977dad 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/ModuleViewModel.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/ModuleViewModel.kt @@ -58,6 +58,13 @@ class ModuleViewModel : ViewModel() { } } + var isNeedRefresh by mutableStateOf(false) + private set + + fun markNeedRefresh() { + isNeedRefresh = true + } + fun fetchModuleList() { viewModelScope.launch(Dispatchers.IO) { isRefreshing = true @@ -91,6 +98,7 @@ class ModuleViewModel : ViewModel() { obj.optString("updateJson", "") ) }.toList() + isNeedRefresh = false }.onFailure { e -> Log.e(TAG, "fetchModuleList: ", e) isRefreshing = false