feat(app): catalogo offline (Room) + cache copertine persistente + refresh all'apertura#9
feat(app): catalogo offline (Room) + cache copertine persistente + refresh all'apertura#9fabiodalez-dev wants to merge 1 commit into
Conversation
…fresh on open Reduces server load and lets the catalog work offline. - Room cache (data/local/): CachedBook entity + CatalogDao (Flow-backed) + AppDatabase store the catalog snapshot locally. CatalogRepository exposes observeCachedCatalog() (offline-first) and refreshCatalog() (fetch page 1, replace the snapshot atomically; a network failure keeps the existing cache). - Home is offline-first: it renders the "Available now" shelf from the cached snapshot immediately (works with no network) and refreshes in the background. - Covers: a persistent 256 MB Coil ImageLoader with respectCacheHeaders(false), so covers are downloaded once and reused instead of re-fetched every time. - Refresh on app open: ProcessLifecycle ON_START refreshes the cache when logged in, so the offline catalog stays current without hammering the server. - First unit-test suite for the app (29 tests): Room CatalogDao (Robolectric, in-memory), entity↔summary mappers, BookSummary availability, reservation cancellable rules, and the URL-derivation helpers. - versionCode 3 -> 4, versionName 1.1.1 -> 1.2.0. Verified: assembleDebug builds; testDebugUnitTest green (29/29).
|
Warning Review limit reached
More reviews will be available in 31 minutes and 57 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Implementa una cache locale per non sovraccaricare il server e far funzionare il catalogo offline (richiesta esplicita).
Cosa fa
data/local/):CachedBook+CatalogDao(Flow) +AppDatabasesalvano uno snapshot del catalogo.CatalogRepositoryesponeobserveCachedCatalog()(offline-first) erefreshCatalog()(scarica la prima pagina e rimpiazza lo snapshot in modo atomico; se la rete fallisce, la cache resta).ImageLoaderCoil persistente da 256 MB conrespectCacheHeaders(false)→ le copertine si scaricano una volta e si riusano, invece di rifarle ogni volta.ProcessLifecycle ON_STARTaggiorna la cache quando sei loggato → il catalogo offline resta aggiornato senza martellare il server.Test (prima suite di test dell'app — 29 test, tutti verdi)
CatalogDaoTest(Robolectric, Room in-memory): insert/observe/ordinamento/replaceAllatomico/clear.CachedBookMapperTest: round-trip entity↔summary.BookSummaryTest: disponibilità derivata.StatusMappingTest: regole di annullabilità prenotazione.NetworkUrlTest: derivazione URL istanza../gradlew testDebugUnitTest→ 29/29 verde.assembleDebugbuilda. versionCode 4 / 1.2.0.Note