From f990e1cffb60f21aeb08b6419152ebf448d4d95f Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Wed, 20 Aug 2025 13:18:45 +0530 Subject: [PATCH] Fixed: Online library sometimes automatically loaded more items without user input. * Removed the code that auto-scrolled the list to show the progress bar. Now, users will see the progress bar only when they scroll down to load more items. * Improved `isLoadingMoreItem` handling to avoid duplicate `loadMore` calls after appending items --- .../nav/destination/library/online/OnlineLibraryScreen.kt | 8 -------- .../kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt index 404f9dd18..a035bd551 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/online/OnlineLibraryScreen.kt @@ -215,14 +215,6 @@ private fun OnlineLibraryList(state: OnlineLibraryScreenState, lazyListState: La showLoadMoreProgressBar(state.isLoadingMoreItem) } - LaunchedEffect(state.isLoadingMoreItem) { - if (state.isLoadingMoreItem) { - // Scroll to the last item (i.e., the loading spinner) - val lastItemIndex = state.onlineLibraryList?.size ?: 0 - lazyListState.animateScrollToItem(lastItemIndex) - } - } - LaunchedEffect(lazyListState) { snapshotFlow { derivedStateOf { diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt index 465154e20..f53c74dc3 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zimManager/ZimManageViewModel.kt @@ -513,6 +513,7 @@ class ZimManageViewModel @Inject constructor( } } .collect { result -> + resetDownloadState() library.emit( if (result.onlineLibraryRequest.isLoadMoreItem) { library.value + result.books @@ -520,7 +521,6 @@ class ZimManageViewModel @Inject constructor( result.books } ) - resetDownloadState() } } }.flowOn(ioDispatcher)