diff --git a/src/components/ActivityEntry.vue b/src/components/ActivityEntry.vue index 7132d9cce..4415689d9 100644 --- a/src/components/ActivityEntry.vue +++ b/src/components/ActivityEntry.vue @@ -26,7 +26,7 @@
- {{ getTime(activity.datetime) }} + {{ relativeDate(activity.datetime) }}
@@ -39,6 +39,7 @@ import RichText from '@juliushaertl/vue-richtext' import { UserBubble } from '@nextcloud/vue' import moment from '@nextcloud/moment' import DOMPurify from 'dompurify' +import relativeDate from '../mixins/relativeDate' const InternalLink = { name: 'InternalLink', @@ -59,6 +60,7 @@ const InternalLink = { } export default { name: 'ActivityEntry', + mixins: [ relativeDate ], components: { RichText, }, @@ -112,15 +114,7 @@ export default { sanitizedMessage() { return DOMPurify.sanitize(this.activity.message, { ALLOWED_TAGS: ['ins', 'del'], ALLOWED_ATTR: ['class'] }) }, - getTime() { - return (timestamp) => { - const diff = moment(this.$root.time).diff(moment(timestamp)) - if (diff >= 0 && diff < 45000) { - return t('core', 'seconds ago') - } - return moment(timestamp).fromNow() - } - }, + }, } diff --git a/src/components/card/CommentItem.vue b/src/components/card/CommentItem.vue index 1c9f87b7e..66241c997 100644 --- a/src/components/card/CommentItem.vue +++ b/src/components/card/CommentItem.vue @@ -27,6 +27,10 @@ +
+
+ {{ relativeDate(comment.creationDateTime) }} +
+ * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import moment from '@nextcloud/moment' + +export default { + computed: { + relativeDate() { + return (timestamp) => { + const diff = moment(this.$root.time).diff(moment(timestamp)) + if (diff >= 0 && diff < 45000) { + return t('core', 'seconds ago') + } + return moment(timestamp).fromNow() + } + }, + }, +}