Skip to content

"Continue Reading" Phase 3: Merge Local Storage Read History into Carousel #13274

Description

@Sadashii

Epic: #13256 — "Continue Reading" Flow & Auto-Add Prompts (open)
This is Phase 3 of that epic. Check the epic issue for overall status and the dependency graph.


Dependencies

The following issues must be merged before work begins on this phase:


Feature Request

Problem / Opportunity

After Phase 1 (#13272) merges active CDL loans and loan history into a single carousel, and Phase 2 (#13273) captures open-access and browse interactions in localStorage, the two data sources still live in isolation. Patrons who read open-access books (which produce no server-side loan record) still see an empty dashboard when all their reading was done through "Read" or "Browse" links.

Success: After this ships, the "My Loans" carousel on My Books surfaces all three reading contexts — active loans, past loan history, and locally tracked open-access reads — so every patron who has touched at least one book sees a populated, personalized dashboard.

Proposal

Extend the unified Loans carousel (built in Phase 1) to also incorporate the client-side localStorage.ol_read_history store (built in Phase 2) as a third, lowest-priority data source:

  • On page load, read localStorage.ol_read_history entries in the frontend.
  • Merge them with the server-rendered active loans + history list, deduplicating by OLID (server-side records take priority).
  • Sort the final merged list by last-access timestamp descending.
  • Render local-storage-only entries as lightweight cards (cover + title only; no loan action buttons since they are not active borrows).

This closes the gap for logged-out patrons and privacy-opt-out patrons: even if they have no server-side reading history, their locally tracked books appear in the carousel as a fallback.

Depends on: #13272 (Phase 1) and #13273 (Phase 2) being merged first.

This is Phase 3 of Epic #13256.


Breakdown

Implementation Details (for maintainers)

Related files

Refer to this map of common Endpoints:

  • openlibrary/plugins/openlibrary/js/my-books/store/readingHistory.js — Phase 2 local storage store (read getHistory())
  • openlibrary/templates/account/mybooks.html — carousel template, needs a JS hook to merge local entries post-render
  • openlibrary/plugins/upstream/mybooks.py — server-side carousel data assembly (Phase 1)
  • openlibrary/plugins/openlibrary/js/my-books/ — JS entry point for carousel augmentation logic [NEW file likely needed]

Requirements Checklist

  • On page load, call getHistory() from the Phase 2 store to retrieve localStorage.ol_read_history
  • Deduplicate against the server-rendered loan OLIDs (server-side wins on conflict)
  • Inject local-storage-only entries as carousel cards (cover image + title, no loan action buttons)
  • Sort final merged carousel by last-access timestamp descending
  • Rename the carousel from "My Loans" to "Continue Reading" in mybooks.html and any associated i18n strings
  • Gracefully handle missing cover images for local-storage entries (show placeholder)
  • No carousel augmentation for logged-in patrons who have server-side data only (local fallback is additive, not replacing)
  • Write JS unit tests for the merge/dedup/sort logic

Stakeholders


Instructions for Contributors

  • Before creating a new branch or pushing up changes to a PR, please first run these commands to ensure your repository is up to date, as the pre-commit bot may add commits to your PRs upstream.
  • JS must be ESLint-compliant, use single quotes, and contain no jQuery.
  • Run npm run test:js to validate merge/dedup logic unit tests pass.

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions