Commit 36376ce5 authored by Tae Hoon's avatar Tae Hoon

use vuex action

parent 45e7f93c
...@@ -71,12 +71,7 @@ const ModerationTools = { ...@@ -71,12 +71,7 @@ const ModerationTools = {
} }
}, },
toggleActivationStatus () { toggleActivationStatus () {
const store = this.$store this.$store.dispatch('toggleActivationStatus', this.user)
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 })
})
}, },
deleteUserDialog (show) { deleteUserDialog (show) {
this.showDeleteUserDialog = show this.showDeleteUserDialog = show
......
...@@ -95,9 +95,9 @@ export const mutations = { ...@@ -95,9 +95,9 @@ export const mutations = {
newRights[right] = value newRights[right] = value
set(user, 'rights', newRights) set(user, 'rights', newRights)
}, },
updateActivationStatus (state, { user: { id }, status }) { updateActivationStatus (state, { user: { id }, deactivated }) {
const user = state.usersObject[id] const user = state.usersObject[id]
set(user, 'deactivated', !status) set(user, 'deactivated', deactivated)
}, },
setCurrentUser (state, user) { setCurrentUser (state, user) {
state.lastLoginName = user.screen_name state.lastLoginName = user.screen_name
...@@ -331,6 +331,12 @@ const users = { ...@@ -331,6 +331,12 @@ const users = {
return rootState.api.backendInteractor.unsubscribeUser(id) return rootState.api.backendInteractor.unsubscribeUser(id)
.then((relationship) => commit('updateUserRelationship', [relationship])) .then((relationship) => commit('updateUserRelationship', [relationship]))
}, },
toggleActivationStatus ({ rootState, commit }, user) {
rootState.api.backendInteractor.toggleActivationStatus(user)
.then(response => {
commit('updateActivationStatus', { user, deactivated: response.deactivated })
})
},
registerPushNotifications (store) { registerPushNotifications (store) {
const token = store.state.currentUser.credentials const token = store.state.currentUser.credentials
const vapidPublicKey = store.rootState.instance.vapidPublicKey const vapidPublicKey = store.rootState.instance.vapidPublicKey
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment