From dc8f0f6feb6c559d2062d8376eb68b6d385d275c Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 8 Jul 2020 01:40:08 -0700 Subject: [PATCH] Bug fixes in modules fragment - Progress is not updated in upgradable modules (and can cause crash) - EndlessRecyclerScrollListener is not reset on new query --- .../com/topjohnwu/magisk/ui/module/ModuleViewModel.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt index 3054dccd8..73205a2aa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt @@ -256,6 +256,7 @@ class ModuleViewModel( } override fun query() { + EndlessRecyclerScrollListener.ResetState().publish() queryJob = viewModelScope.launch { val searched = queryInternal(query, 0) val diff = withContext(Dispatchers.Default) { @@ -277,10 +278,13 @@ class ModuleViewModel( // --- private fun update(repo: Repo, progress: Int) = viewModelScope.launch { - val item = withContext(Dispatchers.Default) { - (itemsRemote + itemsSearch).first { it.item.id == repo.id } + val items = withContext(Dispatchers.Default) { + 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 } } // ---