pleroma-fe/src/components/account_actions/account_actions.js

101 lines
2.9 KiB
JavaScript
Raw Normal View History

import { library } from '@fortawesome/fontawesome-svg-core'
2026-01-06 16:22:52 +02:00
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons'
2026-01-06 16:23:17 +02:00
import UserListMenu from 'src/components/user_list_menu/user_list_menu.vue'
import UserTimedFilterModal from 'src/components/user_timed_filter_modal/user_timed_filter_modal.vue'
2025-02-03 13:02:14 +02:00
import { useReportsStore } from 'src/stores/reports'
2026-01-06 16:23:17 +02:00
import { mapState } from 'vuex'
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import Popover from '../popover/popover.vue'
import ProgressButton from '../progress_button/progress_button.vue'
2026-01-06 16:22:52 +02:00
library.add(faEllipsisV)
2019-10-08 10:21:48 +03:00
const AccountActions = {
2026-01-06 16:22:52 +02:00
props: ['user', 'relationship'],
data() {
2022-02-09 16:26:30 -05:00
return {
2022-09-27 18:47:50 -04:00
showingConfirmBlock: false,
2026-01-06 16:22:52 +02:00
showingConfirmRemoveFollower: false,
2022-02-09 16:26:30 -05:00
}
2019-10-08 10:21:48 +03:00
},
components: {
2020-02-28 16:39:47 +00:00
ProgressButton,
Popover,
2022-02-09 16:26:30 -05:00
UserListMenu,
ConfirmModal,
2026-01-06 16:22:52 +02:00
UserTimedFilterModal,
2019-10-08 10:21:48 +03:00
},
methods: {
2026-01-06 16:22:52 +02:00
showConfirmRemoveUserFromFollowers() {
2022-09-27 18:47:50 -04:00
this.showingConfirmRemoveFollower = true
},
2026-01-06 16:22:52 +02:00
hideConfirmRemoveUserFromFollowers() {
2022-09-27 18:47:50 -04:00
this.showingConfirmRemoveFollower = false
},
2026-01-06 16:22:52 +02:00
hideConfirmBlock() {
this.showingConfirmBlock = false
},
2026-01-06 16:22:52 +02:00
showRepeats() {
2019-10-08 10:21:48 +03:00
this.$store.dispatch('showReblogs', this.user.id)
},
2026-01-06 16:22:52 +02:00
hideRepeats() {
2019-10-08 10:21:48 +03:00
this.$store.dispatch('hideReblogs', this.user.id)
},
2026-01-06 16:22:52 +02:00
blockUser() {
if (this.$refs.timedBlockDialog) {
this.$refs.timedBlockDialog.optionallyPrompt()
2022-02-09 16:26:30 -05:00
} else {
if (!this.shouldConfirmBlock) {
this.doBlockUser()
} else {
this.showingConfirmBlock = true
}
2022-02-09 16:26:30 -05:00
}
},
2026-01-06 16:22:52 +02:00
doBlockUser() {
this.$store.dispatch('blockUser', { id: this.user.id })
2022-02-09 16:26:30 -05:00
this.hideConfirmBlock()
2019-10-08 10:21:48 +03:00
},
2026-01-06 16:22:52 +02:00
unblockUser() {
2019-10-08 10:21:48 +03:00
this.$store.dispatch('unblockUser', this.user.id)
},
2026-01-06 16:22:52 +02:00
removeUserFromFollowers() {
2022-09-27 18:47:50 -04:00
if (!this.shouldConfirmRemoveUserFromFollowers) {
this.doRemoveUserFromFollowers()
} else {
this.showConfirmRemoveUserFromFollowers()
}
},
2026-01-06 16:22:52 +02:00
doRemoveUserFromFollowers() {
this.$store.dispatch('removeUserFromFollowers', this.user.id)
2022-09-27 18:47:50 -04:00
this.hideConfirmRemoveUserFromFollowers()
},
2026-01-06 16:22:52 +02:00
reportUser() {
2023-04-06 17:59:12 -06:00
useReportsStore().openUserReportingModal({ userId: this.user.id })
2020-05-07 16:10:53 +03:00
},
2026-01-06 16:22:52 +02:00
openChat() {
2020-05-07 16:10:53 +03:00
this.$router.push({
name: 'chat',
2026-01-06 16:22:52 +02:00
params: {
username: this.$store.state.users.currentUser.screen_name,
recipient_id: this.user.id,
},
2020-05-07 16:10:53 +03:00
})
2026-01-06 16:22:52 +02:00
},
2020-05-07 16:10:53 +03:00
},
computed: {
2026-01-06 16:22:52 +02:00
shouldConfirmBlock() {
2022-02-09 16:26:30 -05:00
return this.$store.getters.mergedConfig.modalOnBlock
},
2026-01-06 16:22:52 +02:00
shouldConfirmRemoveUserFromFollowers() {
2022-09-27 18:47:50 -04:00
return this.$store.getters.mergedConfig.modalOnRemoveUserFromFollowers
},
2020-05-07 16:10:53 +03:00
...mapState({
2026-01-06 16:22:52 +02:00
blockExpirationSupported: (state) => state.instance.blockExpiration,
pleromaChatMessagesAvailable: (state) =>
state.instance.pleromaChatMessagesAvailable,
}),
},
2019-10-08 10:21:48 +03:00
}
export default AccountActions