Commit dc8f0f6f authored by topjohnwu's avatar topjohnwu

Bug fixes in modules fragment

- Progress is not updated in upgradable modules (and can cause crash)
- EndlessRecyclerScrollListener is not reset on new query
parent 01a43b03
...@@ -256,6 +256,7 @@ class ModuleViewModel( ...@@ -256,6 +256,7 @@ class ModuleViewModel(
} }
override fun query() { override fun query() {
EndlessRecyclerScrollListener.ResetState().publish()
queryJob = viewModelScope.launch { queryJob = viewModelScope.launch {
val searched = queryInternal(query, 0) val searched = queryInternal(query, 0)
val diff = withContext(Dispatchers.Default) { val diff = withContext(Dispatchers.Default) {
...@@ -277,10 +278,13 @@ class ModuleViewModel( ...@@ -277,10 +278,13 @@ class ModuleViewModel(
// --- // ---
private fun update(repo: Repo, progress: Int) = viewModelScope.launch { private fun update(repo: Repo, progress: Int) = viewModelScope.launch {
val item = withContext(Dispatchers.Default) { val items = withContext(Dispatchers.Default) {
(itemsRemote + itemsSearch).first { it.item.id == repo.id } val predicate = { it: RepoItem -> it.item.id == repo.id }
itemsUpdatable.filter(predicate) +
itemsRemote.filter(predicate) +
itemsSearch.filter(predicate)
} }
item.progress.value = progress items.forEach { it.progress.value = progress }
} }
// --- // ---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment