@@ -46,7 +46,7 @@ interface QuestionCardProps {
4646 setQuestions : React . Dispatch < React . SetStateAction < Question [ ] > > ;
4747}
4848
49- function TimeAgo ( { dateString } : { dateString : string } ) {
49+ function TimeAgo ( { dateString, isEdited } : { dateString : string ; isEdited ?: boolean } ) {
5050 const [ timeAgoText , setTimeAgoText ] = useState < string > ( "" ) ;
5151
5252 useEffect ( ( ) => {
@@ -70,7 +70,12 @@ function TimeAgo({ dateString }: { dateString: string }) {
7070 setTimeAgoText ( calculateTimeAgo ( ) ) ;
7171 } , [ dateString ] ) ;
7272
73- return < > { timeAgoText } </ > ;
73+ return (
74+ < >
75+ { timeAgoText }
76+ { isEdited && < span className = "text-gray-400 dark:text-gray-500" > (edited)</ span > }
77+ </ >
78+ ) ;
7479}
7580
7681export default function QuestionCard ( { question, onLike, loggedIn, setQuestions} : QuestionCardProps ) {
@@ -83,6 +88,10 @@ export default function QuestionCard({ question, onLike, loggedIn, setQuestions}
8388
8489 const isOwner = question . author . id === loggedIn . id ;
8590 const { toast } = useToast ( ) ;
91+
92+ // Check if the post has been edited
93+ const isEdited = question . created_at !== question . updated_at ;
94+ const displayDate = isEdited ? question . updated_at : question . created_at ;
8695
8796 // Check if user has already liked this post on mount
8897 useEffect ( ( ) => {
@@ -288,7 +297,7 @@ export default function QuestionCard({ question, onLike, loggedIn, setQuestions}
288297 </ p >
289298 < div className = "flex items-center gap-1 sm:gap-1.5 text-xs sm:text-sm text-gray-500 dark:text-gray-400" >
290299 < Clock className = "h-3 w-3 flex-shrink-0" />
291- < TimeAgo dateString = { question . created_at } />
300+ < TimeAgo dateString = { displayDate } isEdited = { isEdited } />
292301 </ div >
293302 </ div >
294303 </ div >
0 commit comments