Skip to content

Update History live after completing a lesson (#91) - #98

Merged
Muawiya-contact merged 2 commits into
developfrom
fix/91-history-realtime
Sep 5, 2026
Merged

Update History live after completing a lesson (#91)#98
Muawiya-contact merged 2 commits into
developfrom
fix/91-history-realtime

Conversation

@Muawiya-contact

Copy link
Copy Markdown
Member

Closes #91.

Root cause

HistoryScreen reads progress.learned reactively, so it does re-render when
progress changes. The problem was upstream: remoteProgressRepository.markLearned
patched the in-memory cache with a client-side guess — the caller's concept
id, with no title/topic — and never re-fetched. The authoritative history
(/me/state → completed daily_assignments) was only loaded on a full
ProgressContext.load(), i.e. an app restart. So until you restarted, History
showed stale/mismatched data.

Fix

After POST /v1/daily/complete, reload /v1/me/state and return that, so
progress.learned becomes the true server record (correct concept, title, topic)
and History updates in the same session — no restart. The optimistic update in
ProgressContext still shows a row instantly; the reload corrects it a moment
later.

Reload-failure safety (the lesson from the #90 review): if the reload fails, the
completion has already persisted server-side, so patch in place using the streaks
the complete call returned rather than throwing — a succeeded completion is never
rolled back.

Verification

  • npx tsc --noEmit clean. (Mobile has no unit-test harness; this is a
    client-only state-propagation fix.)

Mirrors the same reload-on-mutation pattern used for saved concepts in #96.

markLearned patched the cache with a client-side guess (the caller's concept id,
no title/topic) and only a full reload — an app restart — brought the true server
history. Reload /me/state after /daily/complete so the History tab reflects the
completed concept immediately. If the reload fails the completion has already
persisted, so patch in place rather than rolling it back.
markLearned recorded ProgressContext's locally-selected concept, so a signed-in
user completing the server's concept stored the wrong one — visible on the reload
failure fallback and as a brief wrong-title flash before the reload. Thread the
concept the screen actually showed (the server's, when signed in) into
markLearned, carrying its title and topic into the optimistic/fallback record.

@Muawiya-contact Muawiya-contact left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

History tab doesn't update after completing a lesson

1 participant