Skip to content

Show new posts since last visit with blue left border#2

Open
harijoe wants to merge 1 commit into
mainfrom
harijoe/new-posts-indicator
Open

Show new posts since last visit with blue left border#2
harijoe wants to merge 1 commit into
mainfrom
harijoe/new-posts-indicator

Conversation

@harijoe

@harijoe harijoe commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a visual indicator for posts that are new since the user's last visit. On mount, the VideoList component reads a lastVisitAt timestamp from localStorage, immediately overwrites it with the current time, then compares each video's publish date against the saved timestamp. Posts newer than the previous visit get a blue left border (border-blue-400); all others get a transparent border to keep layout stable. First-time visitors see no indicators, since there is no prior timestamp to compare against.

Architecture Notes

  • localStorage timestamp swap — The old timestamp is read and stored in React state before being overwritten with Date.now(), so the render uses the previous visit's baseline rather than the current one. This ensures newly arrived posts are highlighted only until the next visit.
  • Transparent border as layout anchor — All articles always carry border-l-2; non-new posts use border-transparent instead of removing the border class, preventing a layout shift when the indicator appears after hydration.
  • First-visit safetyseenBefore initialises as null and is only set when a prior key exists in storage, so the isNew check is always false on a first visit.

Uses localStorage to track the last visit timestamp. On subsequent visits,
posts published after the previous visit get a blue left border. First-time
visitors see no indicators.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
theostakes Ready Ready Preview, Comment Apr 7, 2026 4:08pm

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.

1 participant