refs #577 Add block menu to block an account

This commit is contained in:
AkiraFukushima 2018-09-13 00:40:14 +09:00
parent 96654119f5
commit b1d496993a
2 changed files with 16 additions and 3 deletions

View File

@ -32,7 +32,7 @@
<li role="button" @click="unblock(account)" v-if="blocking"> <li role="button" @click="unblock(account)" v-if="blocking">
{{ $t('side_bar.account_profile.unblock') }} {{ $t('side_bar.account_profile.unblock') }}
</li> </li>
<li role="button" @click="confirmBlock(account)" v-else> <li role="button" @click="block(account)" v-else>
{{ $t('side_bar.account_profile.block') }} {{ $t('side_bar.account_profile.block') }}
</li> </li>
</ul> </ul>
@ -194,7 +194,9 @@ export default {
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unmute', account) this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unmute', account)
this.$refs.popper.doClose() this.$refs.popper.doClose()
}, },
confirmBlock () { block (account) {
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/block', account)
this.$refs.popper.doClose()
}, },
unblock () { unblock () {
} }

View File

@ -89,7 +89,7 @@ const AccountProfile = {
close ({ commit }) { close ({ commit }) {
commit('changeAccount', null) commit('changeAccount', null)
}, },
async unmute ({ rootState, commit }, account) { unmute ({ rootState, commit }, account) {
const client = new Mastodon( const client = new Mastodon(
rootState.TimelineSpace.account.accessToken, rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1' rootState.TimelineSpace.account.baseURL + '/api/v1'
@ -99,6 +99,17 @@ const AccountProfile = {
commit('changeRelationship', res.data) commit('changeRelationship', res.data)
return res.data return res.data
}) })
},
block ({ rootState, commit }, account) {
const client = new Mastodon(
rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1'
)
return client.post(`/accounts/${account.id}/block`)
.then(res => {
commit('changeRelationship', res.data)
return res.data
})
} }
} }
} }