Skip to content

unified saved hub and bookmark refactor (Closes #132) - #138

Merged
zeemscript merged 3 commits into
Deen-Bridge:devfrom
Ahbiz:feature/issue-132
Jul 24, 2026
Merged

unified saved hub and bookmark refactor (Closes #132)#138
zeemscript merged 3 commits into
Deen-Bridge:devfrom
Ahbiz:feature/issue-132

Conversation

@Ahbiz

@Ahbiz Ahbiz commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves #132 by creating a unified "Saved" Hub route (/dashboard/saved), consolidating duplicated bookmark hook logic into a shared core, and reducing per-card API check overhead.

What Was Built

1. Unified Saved Hub (/dashboard/saved)

  • Created a dedicated /dashboard/saved route with tabbed navigation ("Saved Courses" and "Saved Books").
  • Learners can now access all their saved courses and library books in one centralized destination.
  • Supports optimistic card removal when unbookmarking items directly from the hub, with automatic rollback and toast notification on failure.
  • Includes skeleton loading states (CourseCardSkeleton, LibraryBookSkeleton), empty state call-to-actions, and NetworkErrorComp error handling.

2. Consolidated Bookmark Hook Core (useBookmarkCore.js)

  • Extracted shared logic from useBookmark and useBookBookmark into a generic useBookmarkCore hook.
  • Refactored useBookmark.js and useBookBookmark.js to act as thin wrappers around useBookmarkCore, keeping all existing exports and signatures 100% backward compatible.
  • Added initialIsBookmarked pre-seeding support so components with known bookmark state bypass unnecessary per-card mount check network requests ($N \to 0$ requests).

3. Reusable BookmarkButton Component (components/atoms/BookmarkButton.jsx)

  • Built a standardized BookmarkButton atom supporting both course and book visual styles.
  • Provides uniform active/inactive bookmark states, loading spinners during network calls, and accessibility labels across cards.

4. Navigation Link

  • Added the "Saved" link with a Bookmark icon to the main dashboard sidebar (components/molecules/dashboard/nav-routers.jsx).

Verification

  • Linting: Executed npm run lint — passed cleanly with 0 errors.
  • Build: Executed npm run build — compiled successfully and generated production route /dashboard/saved.

Closes #132

Summary by CodeRabbit

  • New Features

    • Added a Saved dashboard with separate tabs for saved courses and books.
    • Added navigation access to the Saved dashboard.
    • Added empty states with links to discover courses or books.
    • Added loading placeholders and retry options when saved content cannot be loaded.
  • Improvements

    • Standardized bookmark controls across course and book cards.
    • Saved items now update immediately when bookmarked or unbookmarked.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@Ahbiz is attempting to deploy a commit to the Deen Bridge Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b0f68ea2-f3d4-4fe5-b2a7-0080a202b2e2

📥 Commits

Reviewing files that changed from the base of the PR and between 5d9601e and 48767c6.

📒 Files selected for processing (1)
  • components/molecules/dashboard/nav-routers.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/molecules/dashboard/nav-routers.jsx

Walkthrough

Adds a /dashboard/saved hub for bookmarked courses and books, consolidates bookmark behavior into a shared hook, introduces a reusable bookmark button, updates cards to accept seeded state, and adds Saved navigation.

Changes

Saved hub and bookmark behavior

Layer / File(s) Summary
Shared bookmark state and toggling
hooks/useBookmarkCore.js, hooks/useBookmark.js, hooks/useBookBookmark.js
Course and book hooks now share initialization, bookmark checks, optimistic toggles, reconciliation, authentication, and toast handling through useBookmarkCore.
Shared bookmark controls in cards
components/atoms/BookmarkButton.jsx, components/molecules/dashboard/cards/courseCard.jsx, components/molecules/dashboard/cards/libraryCard.jsx
Both card types use the reusable bookmark control and accept initialIsBookmarked for seeded saved-item state.
Saved dashboard route and navigation
app/dashboard/saved/page.jsx, components/molecules/dashboard/nav-routers.jsx
The Saved page loads courses and books, provides tabs, skeletons, empty and error states, removes unbookmarked items locally, and is linked from dashboard navigation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Learner
  participant SavedPage
  participant CourseCard
  participant LibraryBookCard
  participant useBookmarkCore
  participant BookmarkActions
  Learner->>SavedPage: open Saved route
  SavedPage->>BookmarkActions: fetch saved courses and books
  BookmarkActions-->>SavedPage: return saved items
  SavedPage->>CourseCard: render seeded course bookmarks
  SavedPage->>LibraryBookCard: render seeded book bookmarks
  Learner->>CourseCard: toggle bookmark
  CourseCard->>useBookmarkCore: invoke toggle
  useBookmarkCore->>BookmarkActions: toggle course bookmark
  BookmarkActions-->>useBookmarkCore: return result
  useBookmarkCore-->>SavedPage: report bookmark change
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the new saved hub and bookmark refactor, which matches the main change.
Linked Issues check ✅ Passed The PR adds the Saved hub, shared bookmark core/button, optimistic updates, nav link, and initial state seeding required by #132.
Out of Scope Changes check ✅ Passed The summary shows only changes tied to the Saved hub and bookmark refactor, with no obvious unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/dashboard/saved/page.jsx`:
- Around line 55-65: Update handleCourseBookmarkChange and
handleBookBookmarkChange to cache each optimistically removed course or book,
then restore that cached item when the same callback receives isBookmarked=true
after a failed toggle. Preserve filtering on false, avoid duplicate restoration,
and centralize the shared removal/restoration logic so both handlers support
rollback consistently.

In `@hooks/useBookmarkCore.js`:
- Around line 41-63: Guard the asynchronous checkBookmark response against an
intervening toggle by tracking toggle activity with a ref, and ignore any check
result that becomes stale after toggle() starts or completes. Update the
relevant toggle flow in toggle() and the response handling in checkBookmark so
the confirmed toggle state cannot be overwritten by the mount-time request;
preserve the existing optimistic update and error-revert behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dcdc8636-53ef-4f1e-a939-7e51d41dea8a

📥 Commits

Reviewing files that changed from the base of the PR and between 7db4b0d and 2bf7cc3.

📒 Files selected for processing (9)
  • app/dashboard/saved/page.jsx
  • components/atoms/BookmarkButton.jsx
  • components/molecules/dashboard/cards/courseCard.jsx
  • components/molecules/dashboard/cards/libraryCard.jsx
  • components/molecules/dashboard/nav-routers.jsx
  • hooks/useBookBookmark.js
  • hooks/useBookmark.js
  • hooks/useBookmarkCore.js
  • public/sw.js

Comment thread app/dashboard/saved/page.jsx
Comment thread hooks/useBookmarkCore.js
@zeemscript
zeemscript merged commit f8edf20 into Deen-Bridge:dev Jul 24, 2026
2 of 3 checks passed
zeemscript added a commit that referenced this pull request Jul 24, 2026
Merge pull request #138 from Ahbiz/feature/issue-132

unified saved hub and bookmark refactor (Closes #132)
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.

2 participants