From 13c8f10f4b42c1d698bc99694cd3556c691ac880 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 4 Apr 2019 13:54:52 -0400
Subject: [PATCH] wire up bulk action buttons to vuex
---
src/components/user_settings/user_settings.js | 6 ++++
.../user_settings/user_settings.vue | 4 +--
src/modules/users.js | 36 +++++++++++++------
3 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 022c847b..a9fe84b8 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -355,6 +355,12 @@ const UserSettings = {
this.$store.dispatch('addNewUsers', users)
return map(users, 'id')
})
+ },
+ blockUsers (ids) {
+ return this.$store.dispatch('blockUsers', ids)
+ },
+ unblockUsers (ids) {
+ return this.$store.dispatch('unblockUsers', ids)
}
}
}
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 8bce431a..5e0b71bf 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -203,13 +203,13 @@
-
+
{{ $t('user_card.block') }}
{{ $t('user_card.block_progress') }}
-
+
{{ $t('user_card.unblock') }}
{{ $t('user_card.unblock_progress') }}
diff --git a/src/modules/users.js b/src/modules/users.js
index 58db8b71..a458f681 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -32,6 +32,22 @@ const getNotificationPermission = () => {
return Promise.resolve(Notification.permission)
}
+const blockUser = (store, userId) => {
+ return store.rootState.api.backendInteractor.blockUser(userId)
+ .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 })
+ })
+}
+
+const unblockUser = (store, userId) => {
+ return store.rootState.api.backendInteractor.unblockUser(userId)
+ .then((relationship) => store.commit('updateUserRelationship', [relationship]))
+}
+
export const mutations = {
setMuted (state, { user: { id }, muted }) {
const user = state.usersObject[id]
@@ -207,18 +223,16 @@ const users = {
})
},
blockUser (store, userId) {
- return store.rootState.api.backendInteractor.blockUser(userId)
- .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 })
- })
+ return blockUser(store, userId)
},
- unblockUser (store, id) {
- return store.rootState.api.backendInteractor.unblockUser(id)
- .then((relationship) => store.commit('updateUserRelationship', [relationship]))
+ unblockUser (store, userId) {
+ return unblockUser(store, userId)
+ },
+ blockUsers (store, userIds = []) {
+ return Promise.all(userIds.map(userId => blockUser(store, userId)))
+ },
+ unblockUsers (store, userIds = []) {
+ return Promise.all(userIds.map(userId => unblockUser(store, userId)))
},
fetchMutes (store) {
return store.rootState.api.backendInteractor.fetchMutes()