diff options
| author | tusooa <tusooa@kazv.moe> | 2022-09-11 18:08:00 +0000 |
|---|---|---|
| committer | tusooa <tusooa@kazv.moe> | 2022-09-11 18:08:00 +0000 |
| commit | 2bea5d81288dcf4e231d557b5f1ef338fc1f78f6 (patch) | |
| tree | 67515a1ae88f74a88763a5e769a49ce6715ba73f /src/components/timeago/timeago.vue | |
| parent | de40ebd5ea9c3a89c85d822ee719dce9b48c451a (diff) | |
| parent | ee58e3868c2d58b889d8a32c1b6dfd3732df7584 (diff) | |
Merge branch 'add/edit-status' into 'develop'
Add edit status functionality
See merge request pleroma/pleroma-fe!1537
Diffstat (limited to 'src/components/timeago/timeago.vue')
| -rw-r--r-- | src/components/timeago/timeago.vue | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/components/timeago/timeago.vue b/src/components/timeago/timeago.vue index 2b487dfd..b5f49515 100644 --- a/src/components/timeago/timeago.vue +++ b/src/components/timeago/timeago.vue @@ -3,7 +3,7 @@ :datetime="time" :title="localeDateString" > - {{ $tc(relativeTime.key, relativeTime.num, [relativeTime.num]) }} + {{ relativeTimeString }} </time> </template> @@ -13,7 +13,7 @@ import localeService from 'src/services/locale/locale.service.js' export default { name: 'Timeago', - props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold'], + props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold', 'templateKey'], data () { return { relativeTime: { key: 'time.now', num: 0 }, @@ -26,6 +26,23 @@ export default { return typeof this.time === 'string' ? new Date(Date.parse(this.time)).toLocaleString(browserLocale) : this.time.toLocaleString(browserLocale) + }, + relativeTimeString () { + const timeString = this.$i18n.tc(this.relativeTime.key, this.relativeTime.num, [this.relativeTime.num]) + + if (typeof this.templateKey === 'string' && this.relativeTime.key !== 'time.now') { + return this.$i18n.t(this.templateKey, [timeString]) + } + + return timeString + } + }, + watch: { + time (newVal, oldVal) { + if (oldVal !== newVal) { + clearTimeout(this.interval) + this.refreshRelativeTimeObject() + } } }, created () { |
