diff --git a/packages/concordia-app/package.json b/packages/concordia-app/package.json index f233e96..6b597ea 100644 --- a/packages/concordia-app/package.json +++ b/packages/concordia-app/package.json @@ -45,6 +45,7 @@ "react-router-dom": "^5.2.0", "react-scripts": "~3.4.3", "redux-saga": "~1.1.3", + "react-timeago": "~5.2.0", "semantic-ui-css": "~2.4.1", "semantic-ui-react": "~1.2.1", "web3": "1.3.0" diff --git a/packages/concordia-app/public/locales/en/translation.json b/packages/concordia-app/public/locales/en/translation.json index e8681d5..809fb50 100644 --- a/packages/concordia-app/public/locales/en/translation.json +++ b/packages/concordia-app/public/locales/en/translation.json @@ -51,7 +51,7 @@ "topic.create.form.post.button": "Post", "topic.create.form.subject.field.label": "Topic subject", "topic.create.form.subject.field.placeholder": "Subject", - "topic.list.row.author.date": "Created by {{author}}, {{timeAgo}}", + "topic.list.row.author": "by {{author}}", "topic.list.row.number.of.replies": "{{numberOfReplies}} replies", "topic.list.row.topic.id": "#{{id}}" } diff --git a/packages/concordia-app/src/components/PostList/PostListRow/index.jsx b/packages/concordia-app/src/components/PostList/PostListRow/index.jsx index b107d87..d7c0674 100644 --- a/packages/concordia-app/src/components/PostList/PostListRow/index.jsx +++ b/packages/concordia-app/src/components/PostList/PostListRow/index.jsx @@ -6,7 +6,7 @@ import { } from 'semantic-ui-react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; -import moment from 'moment'; +import TimeAgo from 'react-timeago'; import { useDispatch, useSelector } from 'react-redux'; import { Link } from 'react-router-dom'; import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions'; @@ -40,7 +40,7 @@ const PostListRow = (props) => { if (!loading && postCallHash && getPostResults[postCallHash] !== undefined) { setPostAuthorAddress(getPostResults[postCallHash].value[0]); setPostAuthor(getPostResults[postCallHash].value[1]); - setTimeAgo(moment(getPostResults[postCallHash].value[2] * 1000).fromNow()); + setTimeAgo(getPostResults[postCallHash].value[2] * 1000); } }, [getPostResults, loading, postCallHash]); @@ -132,7 +132,9 @@ const PostListRow = (props) => { ? ( <> {postAuthor} - {timeAgo} + + + > ) : } diff --git a/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx b/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx index 4d25f91..ef59aa9 100644 --- a/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx +++ b/packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx @@ -6,7 +6,7 @@ import { } from 'semantic-ui-react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; -import moment from 'moment'; +import TimeAgo from 'react-timeago'; import { useHistory } from 'react-router'; import { useDispatch, useSelector } from 'react-redux'; import { Link } from 'react-router-dom'; @@ -41,7 +41,7 @@ const TopicListRow = (props) => { if (!loading && topicCallHash && getTopicResults[topicCallHash] !== undefined) { setTopicAuthorAddress(getTopicResults[topicCallHash].value[0]); setTopicAuthor(getTopicResults[topicCallHash].value[1]); - setTimeAgo(moment(getTopicResults[topicCallHash].value[2] * 1000).fromNow()); + setTimeAgo(getTopicResults[topicCallHash].value[2] * 1000); setNumberOfReplies(getTopicResults[topicCallHash].value[3].length); } }, [getTopicResults, loading, topicCallHash]); @@ -151,7 +151,13 @@ const TopicListRow = (props) => { {topicAuthor !== null && timeAgo !== null - ? t('topic.list.row.author.date', { author: topicAuthor, timeAgo }) + ? ( + + {t('topic.list.row.author', { author: topicAuthor })} + , + + + ) : } diff --git a/yarn.lock b/yarn.lock index 90e1b9d..434fb31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14404,6 +14404,11 @@ react-scripts@~3.4.3: optionalDependencies: fsevents "2.1.2" +react-timeago@~5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/react-timeago/-/react-timeago-5.2.0.tgz#d655d40aa55e4fe08a92234481a6aea7f656ab5d" + integrity sha512-wCEEDGQHMdFh/PLp+Hj5vk9ZoC4KjQ5u0u6+KrrY9rny5LqJ2gZvNNEAS4mhSZDV1i7JLgQI5VQTAux7f+vj2w== + react@~16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"