NovelPage(Episode Viewer) depends onnovelInfoProvider.novelInfoProviderfetches data exclusively from the Narou API.- Offline access fails even if episode content is cached, because the metadata (TOC) fetch fails.
Implement a "Network First, Fallback to Database" strategy for Novel Metadata.
- Add functionality to convert
Novel(Drift Database Entity) toNovelInfo(Domain Model). - Note: Cached
NovelInfofrom theNovelstable does not contain theepisodeslist (Table of Contents).
- Modify
novelInfoProviderandnovelInfoWithCacheProvider. - Flow:
- Attempt to fetch
NovelInfofrom API. - Success: Return API data (contains full TOC and
reviseddates). - Failure (Exception):
- Query
AppDatabasefor the novel. - If found: Convert to
NovelInfoand return. - If not found: Rethrow exception (Error screen).
- Query
- Attempt to fetch
-
Online:
NovelInfois fetched from API (ensures fresh TOC andreviseddates).- Episode Content is fetched ONLY IF:
- Not cached locally.
- OR Cached version is older than
reviseddate from TOC.
- This optimizes bandwidth while ensuring content freshness.
-
Offline:
NovelInfois retrieved from DB (Fallback).- Limitations:
episodeslist (TOC) is null/empty.- Latest revision dates are unknown.
- Behavior:
NovelPagereceivesnullforreviseddate.NovelRepositoryskips revision check and returns cached episode content if available.- User can read cached episodes seamlessly.
- Offline:
- Viewer opens successfully using cached metadata (Title, Total Episodes).
- Table of Contents in Viewer might be empty (no episode titles).
- Navigation (Next/Prev) works based on episode numbers.
- Online:
- No change in behavior (Freshness guaranteed, efficient caching used).