Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/StoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { WriterIdentityClient } from "./WriterIdentityClient";
import { RatingSummary } from "./RatingSummary";
import { StoryCardTVL } from "./StoryCardStats";

const DAY_MS = 24 * 60 * 60 * 1000;
function isWithin24h(timestamp: string): boolean {
return Date.now() - new Date(timestamp).getTime() < DAY_MS;
}

export function StoryCard({
storyline,
genre,
Expand All @@ -13,6 +18,9 @@ export function StoryCard({
genre?: string;
}) {
const displayGenre = genre || storyline.genre;
const isNew = storyline.last_plot_time
? isWithin24h(storyline.last_plot_time)
: false;

return (
<div className="flex flex-col">
Expand Down Expand Up @@ -77,6 +85,7 @@ export function StoryCard({
)}
<span className="whitespace-nowrap">
{storyline.plot_count} {storyline.plot_count === 1 ? "plot" : "plots"} linked
{isNew && <span className="text-accent ml-1 text-[10px] font-bold">NEW</span>}
</span>
<RatingSummary storylineId={storyline.storyline_id} />
</div>
Expand Down
Loading