Drumber / Kitsune

Unofficial android app for Kitsu.app (Kitsu.io)
Apache License 2.0
125 stars 9 forks source link

Updated data of library entries is not shown while searching #6

Closed Drumber closed 1 year ago

Drumber commented 1 year ago

Steps to reproduce

  1. Go to the library page
  2. Search for an library entry
  3. Update the library entry (e.g. change progress)
  4. Issue: Updated library data (e.g progress) is not shown
  5. Close the search an the updated library data is visible

Issue cause

Normally, the local database (Room) is the single data source of truth. When making changes to the library, the local database gets updated and the change gets shown in the UI. (Handled using a RemoteMediator) When searching the library, the data source is changed directly to the PagingSource and the local database is ignored: https://github.com/Drumber/Kitsune/blob/fa271ed1ac7b4aebcaa57cba3aee1bff8e1806a4/app/src/main/java/io/github/drumber/kitsune/ui/library/LibraryViewModel.kt#L122-L135

Possible fix

  1. After a library entry was successfully updated, send a new search request to the API to get the updated data.

or

  1. Add a new database table that represents the current UI state, to keep the single source of truth. When performing a library search, the data is put in the database and then shown in the UI.
Drumber commented 1 year ago

Possible fix

1. After a library entry was successfully updated, send a new search request to the API to get the updated data.

Implemented temporary fix in 6ed3a45. However, this should be done probably when reworking the local library database.