Skip to content

fix: fall back to Redux lastReadVerse for Continue Reading surah (#3210) - #3311

Open
Mubashir78 wants to merge 2 commits into
quran:productionfrom
Mubashir78:fix/3210-dashboard-wrong-surah
Open

fix: fall back to Redux lastReadVerse for Continue Reading surah (#3210)#3311
Mubashir78 wants to merge 2 commits into
quran:productionfrom
Mubashir78:fix/3210-dashboard-wrong-surah

Conversation

@Mubashir78

@Mubashir78 Mubashir78 commented Jul 10, 2026

Copy link
Copy Markdown

Fixes #3210

Summary

When a logged-in user navigates to a Surah and then returns to the dashboard, the "Continue Reading" card sometimes shows the wrong Surah (the previously read one instead of the current one).

Root Cause

The dashboard reading section uses a priority chain to resolve the surah shown:

  1. Server-side reading bookmark (verse-level)
  2. Server-side reading bookmark (page-level)
  3. Server-side reading sessions (via useSWRImmutable)

The server-side reading sessions are updated by a debounced API call (addReadingSession) triggered by the intersection observer, which fires only when the user scrolls. Additionally, useSWRImmutable does not re-fetch after the cache is invalidated, so the dashboard may serve stale session data.

The Redux lastReadVerse (via useSyncChapterPage) is updated immediately on every navigation but was not included in the priority chain.

Fix

Added lastReadVerse.chapterId and the corresponding verse number as a fallback in the priority chain, between the server-side reading sessions and the hardcoded default of Surah 1. This ensures the locally-tracked last read verse is used when the server data is stale or unavailable.

Testing

  • Verified the priority chain correctly resolves via effectiveAyahVerseKeyfirstVerseOfStoredPagerecentlyReadVerseKeyslastReadVerse → default 1.
  • The change is minimal (2 lines added to the priority chain, 1 selector import, 1 useSelector call).
  • All existing render paths (guest, logged-in, first-time, mobile) are unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d40aa5a9a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/components/HomePage/ReadingSection/index.tsx
Comment thread src/components/HomePage/ReadingSection/index.tsx Outdated
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.

[bug]: Reading progress shows wrong Surah after returning to dashboard

1 participant