From cd3ed64e48005bc84bdf6cb8e2c33af5caf59481 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 15 Mar 2024 16:02:33 +0800 Subject: [PATCH] Show relative time if boosting/quoting old post --- src/components/status.jsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index eebdfb19..d3389bf5 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -85,6 +85,8 @@ const isIOS = window.ontouchstart !== undefined && /iPad|iPhone|iPod/.test(navigator.userAgent); +const rtf = new Intl.RelativeTimeFormat(); + const REACTIONS_LIMIT = 80; function getPollText(poll) { @@ -508,6 +510,13 @@ function Status({ (attachment) => !attachment.description?.trim?.(), ); }, [mediaAttachments]); + + const statusMonthsAgo = useMemo(() => { + return Math.floor( + (new Date() - createdAtDate) / (1000 * 60 * 60 * 24 * 30), + ); + }, [createdAtDate]); + const boostStatus = async () => { if (!sameInstance || !authenticated) { alert(unauthInteractionErrorMessage); @@ -767,12 +776,22 @@ function Status({ } menuFooter={ - mediaNoDesc && - !reblogged && ( + mediaNoDesc && !reblogged ? ( + ) : ( + statusMonthsAgo >= 3 && ( + + ) ) } disabled={!canBoost}