Add remove follower confirmation

This commit is contained in:
Tusooa Zhu 2022-09-27 18:47:50 -04:00 committed by tusooa
parent 5359633c74
commit ce8101e60a
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
9 changed files with 99 additions and 3 deletions

View File

@ -18,7 +18,8 @@ const AccountActions = {
], ],
data () { data () {
return { return {
showingConfirmBlock: false showingConfirmBlock: false,
showingConfirmRemoveFollower: false
} }
}, },
components: { components: {
@ -34,6 +35,12 @@ const AccountActions = {
hideConfirmBlock () { hideConfirmBlock () {
this.showingConfirmBlock = false this.showingConfirmBlock = false
}, },
showConfirmRemoveUserFromFollowers () {
this.showingConfirmRemoveFollower = true
},
hideConfirmRemoveUserFromFollowers () {
this.showingConfirmRemoveFollower = false
},
showRepeats () { showRepeats () {
this.$store.dispatch('showReblogs', this.user.id) this.$store.dispatch('showReblogs', this.user.id)
}, },
@ -55,7 +62,15 @@ const AccountActions = {
this.$store.dispatch('unblockUser', this.user.id) this.$store.dispatch('unblockUser', this.user.id)
}, },
removeUserFromFollowers () { removeUserFromFollowers () {
if (!this.shouldConfirmRemoveUserFromFollowers) {
this.doRemoveUserFromFollowers()
} else {
this.showConfirmRemoveUserFromFollowers()
}
},
doRemoveUserFromFollowers () {
this.$store.dispatch('removeUserFromFollowers', this.user.id) this.$store.dispatch('removeUserFromFollowers', this.user.id)
this.hideConfirmRemoveUserFromFollowers()
}, },
reportUser () { reportUser () {
this.$store.dispatch('openUserReportingModal', { userId: this.user.id }) this.$store.dispatch('openUserReportingModal', { userId: this.user.id })
@ -71,6 +86,9 @@ const AccountActions = {
shouldConfirmBlock () { shouldConfirmBlock () {
return this.$store.getters.mergedConfig.modalOnBlock return this.$store.getters.mergedConfig.modalOnBlock
}, },
shouldConfirmRemoveUserFromFollowers () {
return this.$store.getters.mergedConfig.modalOnRemoveUserFromFollowers
},
...mapState({ ...mapState({
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
}) })

View File

@ -95,6 +95,27 @@
</i18n-t> </i18n-t>
</confirm-modal> </confirm-modal>
</teleport> </teleport>
<teleport to="#modal">
<confirm-modal
v-if="showingConfirmRemoveFollower"
:title="$t('user_card.remove_follower_confirm_title')"
:confirm-text="$t('user_card.remove_follower_confirm_accept_button')"
:cancel-text="$t('user_card.remove_follower_confirm_cancel_button')"
@accepted="doRemoveUserFromFollowers"
@cancelled="hideConfirmRemoveUserFromFollowers"
>
<i18n-t
keypath="user_card.remove_follower_confirm"
tag="span"
>
<template #user>
<span
v-text="user.screen_name_ui"
/>
</template>
</i18n-t>
</confirm-modal>
</teleport>
</div> </div>
</template> </template>

View File

@ -24,6 +24,7 @@
/> />
<RemoveFollowerButton <RemoveFollowerButton
v-if="noFollowsYou && relationship.followed_by" v-if="noFollowsYou && relationship.followed_by"
:user="user"
:relationship="relationship" :relationship="relationship"
class="follow-card-button" class="follow-card-button"
/> />

View File

@ -1,10 +1,16 @@
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
export default { export default {
props: ['relationship'], props: ['user', 'relationship'],
data () { data () {
return { return {
inProgress: false inProgress: false,
showingConfirmRemoveFollower: false
} }
}, },
components: {
ConfirmModal
},
computed: { computed: {
label () { label () {
if (this.inProgress) { if (this.inProgress) {
@ -12,14 +18,31 @@ export default {
} else { } else {
return this.$t('user_card.remove_follower') return this.$t('user_card.remove_follower')
} }
},
shouldConfirmRemoveUserFromFollowers () {
return this.$store.getters.mergedConfig.modalOnRemoveUserFromFollowers
} }
}, },
methods: { methods: {
showConfirmRemoveUserFromFollowers () {
this.showingConfirmRemoveFollower = true
},
hideConfirmRemoveUserFromFollowers () {
this.showingConfirmRemoveFollower = false
},
onClick () { onClick () {
if (!this.shouldConfirmRemoveUserFromFollowers) {
this.doRemoveUserFromFollowers()
} else {
this.showConfirmRemoveUserFromFollowers()
}
},
doRemoveUserFromFollowers () {
this.inProgress = true this.inProgress = true
this.$store.dispatch('removeUserFromFollowers', this.relationship.id).then(() => { this.$store.dispatch('removeUserFromFollowers', this.relationship.id).then(() => {
this.inProgress = false this.inProgress = false
}) })
this.hideConfirmRemoveUserFromFollowers()
} }
} }
} }

View File

@ -7,6 +7,27 @@
@click="onClick" @click="onClick"
> >
{{ label }} {{ label }}
<teleport to="#modal">
<confirm-modal
v-if="showingConfirmRemoveFollower"
:title="$t('user_card.remove_follower_confirm_title')"
:confirm-text="$t('user_card.remove_follower_confirm_accept_button')"
:cancel-text="$t('user_card.remove_follower_confirm_cancel_button')"
@accepted="doRemoveUserFromFollowers"
@cancelled="hideConfirmRemoveUserFromFollowers"
>
<i18n-t
keypath="user_card.remove_follower_confirm"
tag="span"
>
<template #user>
<span
v-text="user.screen_name_ui"
/>
</template>
</i18n-t>
</confirm-modal>
</teleport>
</button> </button>
</template> </template>

View File

@ -191,6 +191,11 @@
{{ $t('settings.confirm_dialogs_deny_follow') }} {{ $t('settings.confirm_dialogs_deny_follow') }}
</BooleanSetting> </BooleanSetting>
</li> </li>
<li>
<BooleanSetting path="modalOnRemoveUserFromFollowers">
{{ $t('settings.confirm_dialogs_remove_follower') }}
</BooleanSetting>
</li>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -429,6 +429,7 @@
"confirm_dialogs_logout": "logging out", "confirm_dialogs_logout": "logging out",
"confirm_dialogs_approve_follow": "approving a follower", "confirm_dialogs_approve_follow": "approving a follower",
"confirm_dialogs_deny_follow": "denying a follower", "confirm_dialogs_deny_follow": "denying a follower",
"confirm_dialogs_remove_follower": "removing a follower",
"mutes_and_blocks": "Mutes and Blocks", "mutes_and_blocks": "Mutes and Blocks",
"data_import_export_tab": "Data import / export", "data_import_export_tab": "Data import / export",
"default_vis": "Default visibility scope", "default_vis": "Default visibility scope",
@ -964,6 +965,10 @@
"per_day": "per day", "per_day": "per day",
"remote_follow": "Remote follow", "remote_follow": "Remote follow",
"remove_follower": "Remove follower", "remove_follower": "Remove follower",
"remove_follower_confirm_title": "Remove follower confirmation",
"remove_follower_confirm_accept_button": "Remove",
"remove_follower_confirm_cancel_button": "Keep",
"remove_follower_confirm": "Do you really want to remove {user} from your followers?",
"report": "Report", "report": "Report",
"statuses": "Statuses", "statuses": "Statuses",
"subscribe": "Subscribe", "subscribe": "Subscribe",

View File

@ -86,6 +86,7 @@ export const defaultState = {
modalOnLogout: undefined, // instance default modalOnLogout: undefined, // instance default
modalOnApproveFollow: undefined, // instance default modalOnApproveFollow: undefined, // instance default
modalOnDenyFollow: undefined, // instance default modalOnDenyFollow: undefined, // instance default
modalOnRemoveUserFromFollowers: undefined, // instance default
playVideosInModal: false, playVideosInModal: false,
useOneClickNsfw: false, useOneClickNsfw: false,
useContainFit: true, useContainFit: true,

View File

@ -79,6 +79,7 @@ const defaultState = {
modalOnLogout: true, modalOnLogout: true,
modalOnApproveFollow: false, modalOnApproveFollow: false,
modalOnDenyFollow: false, modalOnDenyFollow: false,
modalOnRemoveUserFromFollowers: false,
loginMethod: 'password', loginMethod: 'password',
logo: '/static/logo.svg', logo: '/static/logo.svg',
logoMargin: '.2em', logoMargin: '.2em',