only include direction on timestamps when required #108

Merged
floatingghost merged 2 commits from timeago-fix into develop 2022-08-03 14:07:19 +00:00
3 changed files with 15 additions and 6 deletions

View file

@ -151,6 +151,7 @@
> >
<Timeago <Timeago
:time="notification.created_at" :time="notification.created_at"
:with-direction="true"
:auto-update="240" :auto-update="240"
/> />
</router-link> </router-link>

View file

@ -187,6 +187,7 @@
> >
<Timeago <Timeago
:time="status.created_at" :time="status.created_at"
:with-direction="true"
:auto-update="60" :auto-update="60"
/> />
</router-link> </router-link>

View file

@ -3,12 +3,19 @@
:datetime="time" :datetime="time"
:title="localeDateString" :title="localeDateString"
:class="{ warning: relativeTime.direction === 'time.in_future' }" :class="{ warning: relativeTime.direction === 'time.in_future' }"
>
<template
v-if="withDirection"
> >
{{ {{
relativeTime.direction === '' ? relativeTime.direction === '' ?
$tc(relativeTime.key, relativeTime.num, [relativeTime.num]) : $tc(relativeTime.key, relativeTime.num, [relativeTime.num]) :
$t(relativeTime.direction, [$tc(relativeTime.key, relativeTime.num, [relativeTime.num])]) $t(relativeTime.direction, [$tc(relativeTime.key, relativeTime.num, [relativeTime.num])])
}} }}
</template>
<template v-else>
{{ $tc(relativeTime.key, relativeTime.num, [relativeTime.num]) }}
</template>
</time> </time>
</template> </template>
@ -18,7 +25,7 @@ import localeService from 'src/services/locale/locale.service.js'
export default { export default {
name: 'Timeago', name: 'Timeago',
props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold'], props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold', 'withDirection'],
data () { data () {
return { return {
relativeTime: { key: 'time.now', num: 0 }, relativeTime: { key: 'time.now', num: 0 },