Skip to content

Commit

Permalink
manager: refresh module screen if it comes from install screen. fix #758
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Jul 31, 2023
1 parent d16d3f8 commit d0b8144
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
val viewModel = viewModel<ModuleViewModel>()

LaunchedEffect(Unit) {
if (viewModel.moduleList.isEmpty()) {
if (viewModel.moduleList.isEmpty() || viewModel.isNeedRefresh) {
viewModel.fetchModuleList()
}
}
Expand Down Expand Up @@ -80,6 +80,8 @@ fun ModuleScreen(navigator: DestinationsNavigator) {

navigator.navigate(InstallScreenDestination(uri))

viewModel.markNeedRefresh()

Log.i("ModuleScreen", "select zip result: ${it.data}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +98,7 @@ class ModuleViewModel : ViewModel() {
obj.optString("updateJson", "")
)
}.toList()
isNeedRefresh = false
}.onFailure { e ->
Log.e(TAG, "fetchModuleList: ", e)
isRefreshing = false
Expand Down

0 comments on commit d0b8144

Please sign in to comment.