diff --git a/src/app/profile/[address]/page.tsx b/src/app/profile/[address]/page.tsx index d1acbe49..ae6294ba 100644 --- a/src/app/profile/[address]/page.tsx +++ b/src/app/profile/[address]/page.tsx @@ -19,7 +19,7 @@ import { usePlotUsdPrice } from "../../../hooks/usePlotUsdPrice"; import { formatUsdValue } from "../../../../lib/usd-price"; import { DisconnectButton } from "../../../components/ConnectWallet"; import { GENRES, LANGUAGES } from "../../../../lib/genres"; -import { DeadlineCountdown } from "../../../components/DeadlineCountdown"; +import { DeadlineCountdown, DEADLINE_MS } from "../../../components/DeadlineCountdown"; import { ClaimRoyalties } from "../../../components/ClaimRoyalties"; import { WriterTradingStats } from "../../../components/WriterTradingStats"; import { DropdownSelect } from "../../../components/DropdownSelect"; @@ -868,6 +868,19 @@ function StoryRow({ enabled: !!storyline.token_address, }); + const checkExpired = useCallback( + () => !storyline.sunset && storyline.has_deadline && !!storyline.last_plot_time && + Date.now() > new Date(storyline.last_plot_time).getTime() + DEADLINE_MS, + [storyline.sunset, storyline.has_deadline, storyline.last_plot_time], + ); + const [isExpired, setIsExpired] = useState(checkExpired); + useEffect(() => { + // eslint-disable-next-line react-hooks/set-state-in-effect -- initial sync needed for SSR hydration safety + setIsExpired(checkExpired()); + const interval = setInterval(() => setIsExpired(checkExpired()), 1_000); + return () => clearInterval(interval); + }, [checkExpired]); + return ( <>