Skip to content
Snippets Groups Projects
Verified Commit 40350f05 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Redraw ago datetime every minute

parent 2d12c56b
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,10 @@ export default {
},
created () {
this.$store.dispatch('instance/fetchSettings')
setInterval(() => {
// used to redraw ago dates every minute
self.$store.commit('ui/computeLastDate')
}, 1000 * 60)
}
}
</script>
......
<template>
<time :datetime="date" :title="date | moment">{{ date | ago }}</time>
<time :datetime="date" :title="date | moment">{{ realDate | ago }}</time>
</template>
<script>
import {mapState} from 'vuex'
export default {
props: ['date']
props: ['date'],
computed: {
...mapState({
lastDate: state => state.ui.lastDate
}),
realDate () {
if (this.lastDate) {
// dummy code to trigger a recompute to update the ago render
}
return this.date
}
}
}
</script>
......@@ -8,11 +8,13 @@ import instance from './instance'
import queue from './queue'
import radios from './radios'
import player from './player'
import ui from './ui'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
ui,
auth,
favorites,
instance,
......
export default {
namespaced: true,
state: {
lastDate: new Date()
},
mutations: {
computeLastDate: (state) => {
state.lastDate = new Date()
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment