WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Sep 24, 2025

Fixes #4343

  • Showing category in a dialog on the "Download" screen.
  • Saving the selected category in shared preferences so that it will automatically be applied when the user comes back to the application, similar to the language filter.
  • Fetched the category list from an online source.
  • Applied the category filter while fetching the online content.
  • Created CategoryViewModel to manage UI-related data and user actions.
  • Implemented caching of the category list in the application to avoid unnecessary API calls.
  • Created OnlineCategoryDialog to separately handle the UI and all logic related to the category filter.
  • Added unit and UI test cases for this.
  • Refactored ZimManageViewModelTest to include category filter scenarios.
CategoryFilterInDownloadScreen.mp4

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 75.69620% with 96 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.75%. Comparing base (1da4c8a) to head (79a5d07).

Files with missing lines Patch % Lines
...tion/library/online/viewmodel/CategoryViewModel.kt 72.88% 19 Missing and 13 partials ⚠️
...ation/library/online/OnlineCategoryDialogScreen.kt 80.26% 5 Missing and 10 partials ⚠️
...destination/library/online/OnlineCategoryDialog.kt 72.22% 4 Missing and 6 partials ⚠️
...kiwix/kiwixmobile/core/data/remote/CategoryFeed.kt 57.14% 9 Missing ⚠️
...org/kiwix/kiwixmobile/core/zim_manager/Category.kt 41.66% 7 Missing ⚠️
.../nav/destination/library/online/viewmodel/State.kt 84.61% 2 Missing and 4 partials ⚠️
...iwixmobile/language/viewmodel/LanguageViewModel.kt 0.00% 4 Missing and 1 partial ⚠️
.../library/online/viewmodel/SaveCategoryAndFinish.kt 69.23% 2 Missing and 2 partials ⚠️
...wix/kiwixmobile/core/utils/SharedPreferenceUtil.kt 91.89% 0 Missing and 3 partials ⚠️
...nav/destination/library/online/viewmodel/Action.kt 50.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4436      +/-   ##
============================================
+ Coverage     58.42%   58.75%   +0.33%     
- Complexity     1455     1473      +18     
============================================
  Files           328      337       +9     
  Lines         17016    17405     +389     
  Branches       2101     2151      +50     
============================================
+ Hits           9941    10227     +286     
- Misses         5669     5730      +61     
- Partials       1406     1448      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review September 25, 2025 17:18
@kelson42
Copy link
Collaborator

How does this filter behaves when device if offline? Where does the category list com from then? How work the caching (I wonder why you need one!)?

@MohitMaliFtechiz
Copy link
Collaborator Author

MohitMaliFtechiz commented Sep 26, 2025

How does this filter behaves when device if offline? Where does the category list com from then? How work the caching (I wonder why you need one!)?

@kelson42 We have implemented the caching to store the category in sharedPreference so that the application does not need to fetch the category again and again from an online source(in a single app lifecycle).

Initially, it needs to fetch the category from an online source once, and then it will save that in shared preferences. After that, if there is no internet connection available or any error in fetching the category in the next app lifecycle, then it shows the cached category from the shared preferences. If in the next app lifecycle it fetches the category from an online source, then it saves the updated category in SharedPreferences.

We need the caching to avoid the unnecessary API calls. As it is a separate dialog screen with a viewmodel, in that viewmodel, we fetch the category, and the viewmodel keeps that category data until that screen(dialog) is dismissed. After dismissing the view model, it's clear when the screen is no longer available to free up the resource. If the user again opens this dialog for selecting a different category, then it again fetches the category, so to avoid this fetching, we need this caching. Since keeping this data on the activity level is not good.

* Showing category in a dialog on "Download" screen.
* Saving the selected category in sharedPreference so that it will automatically applied when user came back to the application same as language filter.
* Fetched the category list from online source.
* Applied the category filter while fetching the online content.
* Implemented caching of the category list in the application to avoid unnecessary API calls.
* Created `OnlineCategoryDialog` to separately handle the UI and all logic related to the category filter.
…eTest` unit test cases to cover the entire category filter functionality.

* Refactored `ZimManageViewModelTest` to include category filter scenarios.
* Added `OnlineCategoryTest` UI test.
…e source. Previously, the request could fail due to connection timeouts on slow networks or when the network changed. The retry mechanism is now implemented similarly to the one used for fetching the online library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce the category filter on "Download" screen.

4 participants