manager: refresh module screen if it comes from install screen. fix #758
This commit is contained in:
@@ -52,7 +52,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
val viewModel = viewModel<ModuleViewModel>()
|
val viewModel = viewModel<ModuleViewModel>()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
if (viewModel.moduleList.isEmpty()) {
|
if (viewModel.moduleList.isEmpty() || viewModel.isNeedRefresh) {
|
||||||
viewModel.fetchModuleList()
|
viewModel.fetchModuleList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,6 +80,8 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
|
|
||||||
navigator.navigate(InstallScreenDestination(uri))
|
navigator.navigate(InstallScreenDestination(uri))
|
||||||
|
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
|
||||||
Log.i("ModuleScreen", "select zip result: ${it.data}")
|
Log.i("ModuleScreen", "select zip result: ${it.data}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ class ModuleViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isNeedRefresh by mutableStateOf(false)
|
||||||
|
private set
|
||||||
|
|
||||||
|
fun markNeedRefresh() {
|
||||||
|
isNeedRefresh = true
|
||||||
|
}
|
||||||
|
|
||||||
fun fetchModuleList() {
|
fun fetchModuleList() {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
@@ -91,6 +98,7 @@ class ModuleViewModel : ViewModel() {
|
|||||||
obj.optString("updateJson", "")
|
obj.optString("updateJson", "")
|
||||||
)
|
)
|
||||||
}.toList()
|
}.toList()
|
||||||
|
isNeedRefresh = false
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
Log.e(TAG, "fetchModuleList: ", e)
|
Log.e(TAG, "fetchModuleList: ", e)
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
|
|||||||
Reference in New Issue
Block a user