From d3cad54aa3e72fd83da89b483a9c7522a2695bba Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 4 Apr 2019 14:02:46 -0400
Subject: [PATCH] add bulk mute/unmute buttons and wire up to vuex
---
src/components/user_settings/user_settings.js | 6 ++
.../user_settings/user_settings.vue | 16 +++++
src/modules/users.js | 60 ++++++++++++-------
3 files changed, 59 insertions(+), 23 deletions(-)
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index a9fe84b8..45614ab5 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -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)
}
}
}
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 5e0b71bf..4ce9c55b 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -231,6 +231,22 @@
+
+
+
+ {{ $t('user_card.mute') }}
+
+ {{ $t('user_card.mute_progress') }}
+
+
+
+ {{ $t('user_card.unmute') }}
+
+ {{ $t('user_card.unmute_progress') }}
+
+
+
+
diff --git a/src/modules/users.js b/src/modules/users.js
index a458f681..a5dec794 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -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]