a tool for shared writing and social publishing

add more resolution to timeAgo, show createdAt on comments

+16 -2
+10 -2
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
··· 119 }) => { 120 const did = props.comment.bsky_profiles?.did; 121 122 return ( 123 <div id={props.comment.uri} className="comment"> 124 <div className="flex gap-2"> 125 - {did && ( 126 <ProfilePopover 127 didOrHandle={did} 128 trigger={ ··· 131 </div> 132 } 133 /> 134 - )} 135 </div> 136 {props.record.attachment && 137 PubLeafletComment.isLinearDocumentQuote(props.record.attachment) && (
··· 119 }) => { 120 const did = props.comment.bsky_profiles?.did; 121 122 + let timeAgoDate = timeAgo(props.record.createdAt); 123 + const formattedDate = useLocalizedDate(props.record.createdAt, { 124 + year: "numeric", 125 + month: "long", 126 + day: "2-digit", 127 + }); 128 + 129 return ( 130 <div id={props.comment.uri} className="comment"> 131 <div className="flex gap-2"> 132 + {did ? ( 133 <ProfilePopover 134 didOrHandle={did} 135 trigger={ ··· 138 </div> 139 } 140 /> 141 + ) : null} 142 + <div className="text-sm text-tertiary">{timeAgoDate}</div> 143 </div> 144 {props.record.attachment && 145 PubLeafletComment.isLinearDocumentQuote(props.record.attachment) && (
+6
src/utils/timeAgo.ts
··· 6 const diffMinutes = Math.floor(diffSeconds / 60); 7 const diffHours = Math.floor(diffMinutes / 60); 8 const diffDays = Math.floor(diffHours / 24); 9 const diffYears = Math.floor(diffDays / 365); 10 11 if (diffYears > 0) { 12 return `${diffYears} year${diffYears === 1 ? "" : "s"} ago`; 13 } else if (diffDays > 0) { 14 return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`; 15 } else if (diffHours > 0) {
··· 6 const diffMinutes = Math.floor(diffSeconds / 60); 7 const diffHours = Math.floor(diffMinutes / 60); 8 const diffDays = Math.floor(diffHours / 24); 9 + const diffWeeks = Math.floor(diffDays / 7); 10 + const diffMonths = Math.floor(diffDays / 30); 11 const diffYears = Math.floor(diffDays / 365); 12 13 if (diffYears > 0) { 14 return `${diffYears} year${diffYears === 1 ? "" : "s"} ago`; 15 + } else if (diffMonths > 0) { 16 + return `${diffMonths} month${diffMonths === 1 ? "" : "s"} ago`; 17 + } else if (diffWeeks > 0) { 18 + return `${diffWeeks} week${diffWeeks === 1 ? "" : "s"} ago`; 19 } else if (diffDays > 0) { 20 return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`; 21 } else if (diffHours > 0) {