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

111 lines
3.1 KiB
JavaScript
Raw Normal View History

2026-01-29 20:33:59 +02:00
import { mapState } from 'pinia'
2026-06-03 02:19:25 +03:00
import { defineAsyncComponent } from 'vue'
2026-01-08 17:26:52 +02:00
import Popover from 'src/components/popover/popover.vue'
import ProgressButton from 'src/components/progress_button/progress_button.vue'
2026-06-04 21:59:09 +03:00
import UserListMenu from 'src/components/user_list_menu/user_list_menu.vue'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
2026-01-29 20:40:00 +02:00
import { useReportsStore } from 'src/stores/reports'
2026-01-08 17:26:52 +02:00
import { library } from '@fortawesome/fontawesome-svg-core'
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons'
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,
2026-06-03 02:19:25 +03:00
ConfirmModal: defineAsyncComponent(
() => import('src/components/confirm_modal/confirm_modal.vue'),
),
2026-06-04 19:52:38 +03:00
UserTimedFilterModal: defineAsyncComponent(
2026-06-04 21:59:09 +03:00
() =>
import(
'src/components/user_timed_filter_modal/user_timed_filter_modal.vue'
),
2026-06-04 19:52:38 +03:00
),
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() {
return useMergedConfigStore().mergedConfig.modalOnBlock
2022-02-09 16:26:30 -05:00
},
2026-01-06 16:22:52 +02:00
shouldConfirmRemoveUserFromFollowers() {
return useMergedConfigStore().mergedConfig.modalOnRemoveUserFromFollowers
2022-09-27 18:47:50 -04:00
},
...mapState(useInstanceCapabilitiesStore, [
'blockExpiration',
'pleromaChatMessagesAvailable',
]),
2026-01-06 16:22:52 +02:00
},
2019-10-08 10:21:48 +03:00
}
export default AccountActions