feat: pre-fetch email bodies for offline access #400

Merged
guettlibot merged 1 commits from refs/pull/400/head into main 2026-06-04 04:15:04 +00:00
1 Commits
Author SHA1 Message Date
Thomas SharedInboxandClaude Sonnet 4.6 49fdf83834 feat: pre-fetch email bodies for offline access (#373)
Adds a background body-prefetch mechanism with network-awareness and a
user-configurable cache size limit to keep email bodies available offline
without downloading the entire mailbox.

- Schema v38: adds `prefetch_mode` and `body_cache_limit_mb` columns to
  `user_preferences` (defaults: wifiOnly / 100 MB).
- `PrefetchMode` enum (disabled / wifiOnly / always) in the model.
- `BodyCacheService`: fetches bodies for uncached emails (newest first,
  batch of 20), evicts oldest cached bodies when the size limit is
  exceeded.
- Registers a separate WorkManager periodic task (`si_bg_prefetch`) with
  `NetworkType.unmetered` (Wi-Fi only) or `NetworkType.connected` (any)
  based on the stored preference; cancels the task when disabled.
- On app startup, reads the stored preference and re-registers the task
  with the correct constraint.
- Preferences screen: radio group for prefetch mode + dropdown for
  cache size limit (50 / 100 / 200 / 500 MB).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 03:29:03 +02:00