feature/version-gated-updates #1

Merged
fredo merged 5 commits from feature/version-gated-updates into main 2026-09-09 21:59:41 +02:00
Owner

Changed the update model

Changed the update model
NetworkRepository contained a working version-check implementation but
was never called. Version.kt and VersionInfo.kt in data/model are
duplicate definitions of VersionInfo already declared in
MedicationApiService.kt. All three are referenced nowhere outside
their own files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Convert interface to abstract class so Room can generate a concrete
@Transaction method. replaceAll() wraps deleteAll() + insertAll() in a
single transaction, ensuring a mid-insert failure leaves the DB
unchanged rather than empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Refresh sequence now:
  1. GET /version.json, validate explicitly (no trusting Gson non-nulls)
  2. Compare server version to stored version for current language
  3. If equal: update last_checked_at only, skip the ~1.1 MB download
  4. If newer: download, validate (non-empty and >= 80% of current
     count), replace transactionally via MedicationDao.replaceAll(),
     then persist dataVersion + dataPublishedAt + lastCheckedAt

Single OkHttp client with 5 MB cache replaces the two separate
Retrofit instances that existed before. MedicationApiService.create()
now takes a cacheDir to enable ETag/If-None-Match on the
nginx-served static files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DataStatus carries dataVersion, dataPublishedAt, and lastCheckedAt.
The ViewModel loads the initial status from SharedPreferences on init
and refreshes it after every refresh/language-switch operation.

MedicationListScreen shows a status row at the top of the list:
- amber warning when never checked or last check > 30 days ago
- quiet text line otherwise: "Données du <date> · vérifié <when>"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Split _isLoading into two states:
- _isInitializing: true only during first-time DB population, shows
  the full-screen spinner (list has nothing to show yet)
- _isRefreshing: true during network refresh, language switch, and
  export, shows only a thin LinearProgressIndicator below the search
  bar — the medication list stays visible throughout

The menu and search field are disabled during both states to prevent
double-taps. Language switch benefits from the @Transaction replaceAll
added earlier: Room only emits a new list once the transaction commits,
so the old language's data stays visible until the new data is ready.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fredo merged commit 8e64c610de into main 2026-09-09 21:59:41 +02:00
fredo deleted branch feature/version-gated-updates 2026-09-12 18:49:02 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
fredo/Compendium!1
No description provided.