aboutsummaryrefslogtreecommitdiff
path: root/src/components/lists_timeline/lists_timeline.js
blob: 7534420d72d1f55a5c4d6e412651e967c16ba31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Timeline from '../timeline/timeline.vue'
const ListsTimeline = {
  data () {
    return {
      listId: null
    }
  },
  components: {
    Timeline
  },
  computed: {
    timeline () { return this.$store.state.statuses.timelines.list }
  },
  watch: {
    $route: function (route) {
      if (route.name === 'lists-timeline' && route.params.id !== this.listId) {
        this.listId = route.params.id
        this.$store.dispatch('stopFetchingTimeline', 'list')
        this.$store.commit('clearTimeline', { timeline: 'list' })
        this.$store.dispatch('fetchList', { id: this.listId })
        this.$store.dispatch('startFetchingTimeline', { timeline: 'list', listId: this.listId })
      }
    }
  },
  created () {
    this.listId = this.$route.params.id
    this.$store.dispatch('fetchList', { id: this.listId })
    this.$store.dispatch('startFetchingTimeline', { timeline: 'list', listId: this.listId })
  },
  unmounted () {
    this.$store.dispatch('stopFetchingTimeline', 'list')
    this.$store.commit('clearTimeline', { timeline: 'list' })
  }
}

export default ListsTimeline