forked from srxl/akkoma-fe
add bulk mute/unmute buttons and wire up to vuex
This commit is contained in:
parent
13c8f10f4b
commit
d3cad54aa3
3 changed files with 59 additions and 23 deletions
|
@ -361,6 +361,12 @@ const UserSettings = {
|
|||
},
|
||||
unblockUsers (ids) {
|
||||
return this.$store.dispatch('unblockUsers', ids)
|
||||
},
|
||||
muteUsers (ids) {
|
||||
return this.$store.dispatch('muteUsers', ids)
|
||||
},
|
||||
unmuteUsers (ids) {
|
||||
return this.$store.dispatch('unmuteUsers', ids)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,6 +231,22 @@
|
|||
</Autosuggest>
|
||||
</div>
|
||||
<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">
|
||||
<MuteCard :userId="p.item" />
|
||||
</template>
|
||||
|
|
|
@ -32,19 +32,32 @@ const getNotificationPermission = () => {
|
|||
return Promise.resolve(Notification.permission)
|
||||
}
|
||||
|
||||
const blockUser = (store, userId) => {
|
||||
return store.rootState.api.backendInteractor.blockUser(userId)
|
||||
const blockUser = (store, id) => {
|
||||
return store.rootState.api.backendInteractor.blockUser(id)
|
||||
.then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
store.commit('addBlockId', userId)
|
||||
store.commit('removeStatus', { timeline: 'friends', userId })
|
||||
store.commit('removeStatus', { timeline: 'public', userId })
|
||||
store.commit('removeStatus', { timeline: 'publicAndExternal', userId })
|
||||
store.commit('addBlockId', id)
|
||||
store.commit('removeStatus', { timeline: 'friends', userId: id })
|
||||
store.commit('removeStatus', { timeline: 'public', userId: id })
|
||||
store.commit('removeStatus', { timeline: 'publicAndExternal', userId: id })
|
||||
})
|
||||
}
|
||||
|
||||
const unblockUser = (store, userId) => {
|
||||
return store.rootState.api.backendInteractor.unblockUser(userId)
|
||||
const unblockUser = (store, id) => {
|
||||
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]))
|
||||
}
|
||||
|
||||
|
@ -222,17 +235,17 @@ const users = {
|
|||
return blocks
|
||||
})
|
||||
},
|
||||
blockUser (store, userId) {
|
||||
return blockUser(store, userId)
|
||||
blockUser (store, id) {
|
||||
return blockUser(store, id)
|
||||
},
|
||||
unblockUser (store, userId) {
|
||||
return unblockUser(store, userId)
|
||||
unblockUser (store, id) {
|
||||
return unblockUser(store, id)
|
||||
},
|
||||
blockUsers (store, userIds = []) {
|
||||
return Promise.all(userIds.map(userId => blockUser(store, userId)))
|
||||
blockUsers (store, ids = []) {
|
||||
return Promise.all(ids.map(id => blockUser(store, id)))
|
||||
},
|
||||
unblockUsers (store, userIds = []) {
|
||||
return Promise.all(userIds.map(userId => unblockUser(store, userId)))
|
||||
unblockUsers (store, ids = []) {
|
||||
return Promise.all(ids.map(id => unblockUser(store, id)))
|
||||
},
|
||||
fetchMutes (store) {
|
||||
return store.rootState.api.backendInteractor.fetchMutes()
|
||||
|
@ -243,15 +256,16 @@ const users = {
|
|||
})
|
||||
},
|
||||
muteUser (store, id) {
|
||||
return store.rootState.api.backendInteractor.muteUser(id)
|
||||
.then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
store.commit('addMuteId', id)
|
||||
})
|
||||
return muteUser(store, id)
|
||||
},
|
||||
unmuteUser (store, id) {
|
||||
return store.rootState.api.backendInteractor.unmuteUser(id)
|
||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
return unmuteUser(store, id)
|
||||
},
|
||||
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) {
|
||||
const user = rootState.users.usersObject[id]
|
||||
|
|
Loading…
Reference in a new issue