aboutsummaryrefslogtreecommitdiff
path: root/src/components/retweet_button/retweet_button.js
blob: d9a0f92e61ddeeab70b44faf71edb7aadff0cfcf (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
import { mapGetters } from 'vuex'

const RetweetButton = {
  props: ['status', 'loggedIn', 'visibility'],
  data () {
    return {
      animated: false
    }
  },
  methods: {
    retweet () {
      if (!this.status.repeated) {
        this.$store.dispatch('retweet', { id: this.status.id })
      } else {
        this.$store.dispatch('unretweet', { id: this.status.id })
      }
      this.animated = true
      setTimeout(() => {
        this.animated = false
      }, 500)
    }
  },
  computed: {
    classes () {
      return {
        'retweeted': this.status.repeated,
        'retweeted-empty': !this.status.repeated,
        'animate-spin': this.animated
      }
    },
    ...mapGetters(['mergedConfig'])
  }
}

export default RetweetButton