Skip to content

feat(frontend): add Recently Viewed dashboard section#152

Open
AYUSH-P-SINGH wants to merge 2 commits into
ARUNNG2004:mainfrom
AYUSH-P-SINGH:feat/recently-viewed-posts
Open

feat(frontend): add Recently Viewed dashboard section#152
AYUSH-P-SINGH wants to merge 2 commits into
ARUNNG2004:mainfrom
AYUSH-P-SINGH:feat/recently-viewed-posts

Conversation

@AYUSH-P-SINGH

Copy link
Copy Markdown

Pull Request Description

Summary

This PR introduces a complete Recently Viewed Posts feature, allowing authenticated users to keep track of posts they have recently opened and revisit them directly from the dashboard.

The feature includes backend APIs for storing and retrieving viewing history, along with a new dashboard section that displays recently viewed posts with smooth navigation back to the original post in the feed.


What This PR Does

Backend

Enhanced the /api/posts/view API with support for both updating and retrieving recently viewed posts.

POST /api/posts/view

  • Records a viewed post for an authenticated user.
  • Removes duplicate entries before inserting the latest view.
  • Moves previously viewed posts back to the top of the history.
  • Limits the history to the 10 most recent unique posts.
  • Stores the updated history in the user's Firestore document.

GET /api/posts/view

  • Retrieves the user's recently viewed post IDs.
  • Fetches complete post metadata while preserving the stored viewing order.
  • Returns the latest viewed posts for dashboard display.

Frontend

Implemented a dedicated Recently Viewed section within the dashboard.

New Component

RecentlyViewed.js

  • Displays recently viewed posts as responsive cards.
  • Shows post snippets, post type tags, and engagement statistics.
  • Includes an empty-state view when no history exists.
  • Adds hover effects and consistent dashboard styling.

Dashboard Integration

LeftSidebar.js

  • Added a Recently Viewed navigation item for desktop users.

FeedColumn.js

  • Added a Recently Viewed tab for mobile users.
  • Renders the RecentlyViewed component when selected.

page.js

  • Manages recently viewed state.
  • Fetches history when the tab becomes active.
  • Updates history when users expand a post's comments.
  • Implements smooth scrolling back to the selected post within the main feed using hash-based navigation.

Files Changed

New

  • RecentlyViewed.js

Modified

  • app/api/posts/view/route.js
  • LeftSidebar.js
  • FeedColumn.js
  • page.js

Testing

Backend

  • ✅ Verified POST endpoint correctly updates recently viewed history.
  • ✅ Verified duplicate views move posts to the top of the list.
  • ✅ Confirmed history is limited to 10 unique posts.
  • ✅ Verified GET endpoint returns posts in the correct viewing order.

Frontend

  • ✅ Verified recently viewed posts render correctly.
  • ✅ Confirmed smooth navigation back to posts from the history list.
  • ✅ Tested desktop sidebar and mobile tab integration.
  • ✅ Verified empty-state rendering when no viewed posts exist.

Project Validation

  • npm run check:structure
  • npm run build

Both completed successfully.


Type of Change

  • ✅ ✨ New feature (non-breaking change)

Checklist

  • ✅ My code follows the project's coding standards.
  • ✅ I have performed a self-review of my code.
  • ✅ My changes introduce no new warnings or errors.
  • ✅ Existing functionality remains unaffected.
  • ✅ The feature has been tested locally.

FIXES #150

@netlify

netlify Bot commented Jul 11, 2026

Copy link
Copy Markdown

👷 Deploy request for devconnectai pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b5c0ee7

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.

FEATURE(UI/FRONTEND): Add "Recently Viewed Posts" UI Section

1 participant