add bulk mute/unmute buttons and wire up to vuex

This commit is contained in:
taehoon 2019-04-04 14:02:46 -04:00
parent 13c8f10f4b
commit d3cad54aa3
3 changed files with 59 additions and 23 deletions

View file

@ -361,6 +361,12 @@ const UserSettings = {
}, },
unblockUsers (ids) { unblockUsers (ids) {
return this.$store.dispatch('unblockUsers', ids) return this.$store.dispatch('unblockUsers', ids)
},
muteUsers (ids) {
return this.$store.dispatch('muteUsers', ids)
},
unmuteUsers (ids) {
return this.$store.dispatch('unmuteUsers', ids)
} }
} }
} }

View file

@ -231,6 +231,22 @@
</Autosuggest> </Autosuggest>
</div> </div>
<MuteList :refresh="true" :getKey="item => item"> <MuteList :refresh="true" :getKey="item => item">
<template slot="header" slot-scope="p">
<div class="bulk-actions-wrapper">
<ProgressButton class="btn btn-default" v-if="p.selected.length > 0" :click="() => muteUsers(p.selected)">
{{ $t('user_card.mute') }}
<template slot="progress">
{{ $t('user_card.mute_progress') }}
</template>
</ProgressButton>
<ProgressButton class="btn btn-default" v-if="p.selected.length > 0" :click="() => unmuteUsers(p.selected)">
{{ $t('user_card.unmute') }}
<template slot="progress">
{{ $t('user_card.unmute_progress') }}
</template>
</ProgressButton>
</div>
</template>
<template slot="item" slot-scope="p"> <template slot="item" slot-scope="p">
<MuteCard :userId="p.item" /> <MuteCard :userId="p.item" />
</template> </template>

View file

@ -32,19 +32,32 @@ const getNotificationPermission = () => {
return Promise.resolve(Notification.permission) return Promise.resolve(Notification.permission)
} }
const blockUser = (store, userId) => { const blockUser = (store, id) => {
return store.rootState.api.backendInteractor.blockUser(userId) return store.rootState.api.backendInteractor.blockUser(id)
.then((relationship) => { .then((relationship) => {
store.commit('updateUserRelationship', [relationship]) store.commit('updateUserRelationship', [relationship])
store.commit('addBlockId', userId) store.commit('addBlockId', id)
store.commit('removeStatus', { timeline: 'friends', userId }) store.commit('removeStatus', { timeline: 'friends', userId: id })
store.commit('removeStatus', { timeline: 'public', userId }) store.commit('removeStatus', { timeline: 'public', userId: id })
store.commit('removeStatus', { timeline: 'publicAndExternal', userId }) store.commit('removeStatus', { timeline: 'publicAndExternal', userId: id })
}) })
} }
const unblockUser = (store, userId) => { const unblockUser = (store, id) => {
return store.rootState.api.backendInteractor.unblockUser(userId) return store.rootState.api.backendInteractor.unblockUser(id)
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
}
const muteUser = (store, id) => {
return store.rootState.api.backendInteractor.muteUser(id)
.then((relationship) => {
store.commit('updateUserRelationship', [relationship])
store.commit('addMuteId', id)
})
}
const unmuteUser = (store, id) => {
return store.rootState.api.backendInteractor.unmuteUser(id)
.then((relationship) => store.commit('updateUserRelationship', [relationship])) .then((relationship) => store.commit('updateUserRelationship', [relationship]))
} }
@ -222,17 +235,17 @@ const users = {
return blocks return blocks
}) })
}, },
blockUser (store, userId) { blockUser (store, id) {
return blockUser(store, userId) return blockUser(store, id)
}, },
unblockUser (store, userId) { unblockUser (store, id) {
return unblockUser(store, userId) return unblockUser(store, id)
}, },
blockUsers (store, userIds = []) { blockUsers (store, ids = []) {
return Promise.all(userIds.map(userId => blockUser(store, userId))) return Promise.all(ids.map(id => blockUser(store, id)))
}, },
unblockUsers (store, userIds = []) { unblockUsers (store, ids = []) {
return Promise.all(userIds.map(userId => unblockUser(store, userId))) return Promise.all(ids.map(id => unblockUser(store, id)))
}, },
fetchMutes (store) { fetchMutes (store) {
return store.rootState.api.backendInteractor.fetchMutes() return store.rootState.api.backendInteractor.fetchMutes()
@ -243,15 +256,16 @@ const users = {
}) })
}, },
muteUser (store, id) { muteUser (store, id) {
return store.rootState.api.backendInteractor.muteUser(id) return muteUser(store, id)
.then((relationship) => {
store.commit('updateUserRelationship', [relationship])
store.commit('addMuteId', id)
})
}, },
unmuteUser (store, id) { unmuteUser (store, id) {
return store.rootState.api.backendInteractor.unmuteUser(id) return unmuteUser(store, id)
.then((relationship) => store.commit('updateUserRelationship', [relationship])) },
muteUsers (store, ids = []) {
return Promise.all(ids.map(id => muteUser(store, id)))
},
unmuteUsers (store, ids = []) {
return Promise.all(ids.map(id => unmuteUser(store, id)))
}, },
fetchFriends ({ rootState, commit }, id) { fetchFriends ({ rootState, commit }, id) {
const user = rootState.users.usersObject[id] const user = rootState.users.usersObject[id]