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

48 lines
1.2 KiB
JavaScript
Raw Normal View History

import { mapState } from 'vuex'
2019-02-13 14:55:02 -05:00
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
const BlockCard = {
2019-02-13 15:31:20 -05:00
props: ['userId'],
computed: {
2026-01-06 16:22:52 +02:00
user() {
return this.$store.getters.findUser(this.userId)
2019-02-13 15:31:20 -05:00
},
2026-01-06 16:22:52 +02:00
relationship() {
return this.$store.getters.relationship(this.userId)
2020-04-21 23:27:51 +03:00
},
2026-01-06 16:22:52 +02:00
blocked() {
2020-04-21 23:27:51 +03:00
return this.relationship.blocking
},
2026-01-06 16:22:52 +02:00
blockExpiryAvailable() {
2025-07-17 14:53:56 +03:00
return this.user.block_expires_at !== undefined
},
2026-01-06 16:22:52 +02:00
blockExpiry() {
return this.user.block_expires_at == null
? this.$t('user_card.block_expires_forever')
2026-01-06 16:22:52 +02:00
: this.$t('user_card.block_expires_at', [
new Date(this.user.mute_expires_at).toLocaleString(),
])
},
...mapState({
2026-01-06 16:22:52 +02:00
blockExpirationSupported: (state) => state.instance.blockExpiration,
}),
2019-02-13 14:55:02 -05:00
},
components: {
2026-01-06 16:22:52 +02:00
BasicUserCard,
2019-02-13 14:55:02 -05:00
},
methods: {
2026-01-06 16:22:52 +02:00
unblockUser() {
this.$store.dispatch('unblockUser', this.user.id)
2019-02-13 15:31:20 -05:00
},
2026-01-06 16:22:52 +02:00
blockUser() {
if (this.blockExpirationSupported) {
this.$refs.timedBlockDialog.optionallyPrompt()
} else {
this.$store.dispatch('blockUser', { id: this.user.id })
}
2026-01-06 16:22:52 +02:00
},
},
2019-02-13 14:55:02 -05:00
}
export default BlockCard