aboutsummaryrefslogtreecommitdiff
path: root/src/components/account_actions/account_actions.js
blob: acd93e06501c41e4a2cc9e1c99ec223b36b530eb (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { mapState } from 'vuex'
import ProgressButton from '../progress_button/progress_button.vue'
import Popover from '../popover/popover.vue'
import UserListMenu from 'src/components/user_list_menu/user_list_menu.vue'
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
  faEllipsisV
} from '@fortawesome/free-solid-svg-icons'

library.add(
  faEllipsisV
)

const AccountActions = {
  props: [
    'user', 'relationship'
  ],
  data () {
    return {
      showingConfirmBlock: false,
      showingConfirmRemoveFollower: false
    }
  },
  components: {
    ProgressButton,
    Popover,
    UserListMenu,
    ConfirmModal
  },
  methods: {
    showConfirmBlock () {
      this.showingConfirmBlock = true
    },
    hideConfirmBlock () {
      this.showingConfirmBlock = false
    },
    showConfirmRemoveUserFromFollowers () {
      this.showingConfirmRemoveFollower = true
    },
    hideConfirmRemoveUserFromFollowers () {
      this.showingConfirmRemoveFollower = false
    },
    showRepeats () {
      this.$store.dispatch('showReblogs', this.user.id)
    },
    hideRepeats () {
      this.$store.dispatch('hideReblogs', this.user.id)
    },
    blockUser () {
      if (!this.shouldConfirmBlock) {
        this.doBlockUser()
      } else {
        this.showConfirmBlock()
      }
    },
    doBlockUser () {
      this.$store.dispatch('blockUser', this.user.id)
      this.hideConfirmBlock()
    },
    unblockUser () {
      this.$store.dispatch('unblockUser', this.user.id)
    },
    removeUserFromFollowers () {
      if (!this.shouldConfirmRemoveUserFromFollowers) {
        this.doRemoveUserFromFollowers()
      } else {
        this.showConfirmRemoveUserFromFollowers()
      }
    },
    doRemoveUserFromFollowers () {
      this.$store.dispatch('removeUserFromFollowers', this.user.id)
      this.hideConfirmRemoveUserFromFollowers()
    },
    reportUser () {
      this.$store.dispatch('openUserReportingModal', { userId: this.user.id })
    },
    openChat () {
      this.$router.push({
        name: 'chat',
        params: { username: this.$store.state.users.currentUser.screen_name, recipient_id: this.user.id }
      })
    }
  },
  computed: {
    shouldConfirmBlock () {
      return this.$store.getters.mergedConfig.modalOnBlock
    },
    shouldConfirmRemoveUserFromFollowers () {
      return this.$store.getters.mergedConfig.modalOnRemoveUserFromFollowers
    },
    ...mapState({
      pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
    })
  }
}

export default AccountActions