From 36376ce57c93c81317b6a8b0b50699d6b8488f57 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Mon, 18 Nov 2019 20:42:10 -0500
Subject: [PATCH] use vuex action
---
src/components/moderation_tools/moderation_tools.js | 7 +------
src/modules/users.js | 10 ++++++++--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js
index 10a20709..02b92fef 100644
--- a/src/components/moderation_tools/moderation_tools.js
+++ b/src/components/moderation_tools/moderation_tools.js
@@ -71,12 +71,7 @@ const ModerationTools = {
}
},
toggleActivationStatus () {
- const store = this.$store
- const status = !!this.user.deactivated
- store.state.api.backendInteractor.toggleActivationStatus(this.user).then(response => {
- if (!response.ok) { return }
- store.commit('updateActivationStatus', { user: this.user, status: status })
- })
+ this.$store.dispatch('toggleActivationStatus', this.user)
},
deleteUserDialog (show) {
this.showDeleteUserDialog = show
diff --git a/src/modules/users.js b/src/modules/users.js
index 14b2d8b5..ec2ef608 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -95,9 +95,9 @@ export const mutations = {
newRights[right] = value
set(user, 'rights', newRights)
},
- updateActivationStatus (state, { user: { id }, status }) {
+ updateActivationStatus (state, { user: { id }, deactivated }) {
const user = state.usersObject[id]
- set(user, 'deactivated', !status)
+ set(user, 'deactivated', deactivated)
},
setCurrentUser (state, user) {
state.lastLoginName = user.screen_name
@@ -331,6 +331,12 @@ const users = {
return rootState.api.backendInteractor.unsubscribeUser(id)
.then((relationship) => commit('updateUserRelationship', [relationship]))
},
+ toggleActivationStatus ({ rootState, commit }, user) {
+ rootState.api.backendInteractor.toggleActivationStatus(user)
+ .then(response => {
+ commit('updateActivationStatus', { user, deactivated: response.deactivated })
+ })
+ },
registerPushNotifications (store) {
const token = store.state.currentUser.credentials
const vapidPublicKey = store.rootState.instance.vapidPublicKey