Update currentUser with $store.commit

I find this much cleaner that to dispatch `fetchCurrentUser`. It gets
along with one less request, too.
This commit is contained in:
Robert Schäfer 2019-02-27 11:06:23 +01:00
parent ea9f896ef8
commit 41072e6fa8

View File

@ -48,7 +48,7 @@
<script>
import gql from 'graphql-tag'
import { mapGetters } from 'vuex'
import { mapGetters, mapMutations } from 'vuex'
import { CancelToken } from 'axios'
import find from 'lodash/find'
@ -99,6 +99,9 @@ export default {
computed: {
...mapGetters({
currentUser: 'auth/user'
}),
...mapMutations({
currentUser: 'auth/user'
})
},
watch: {
@ -135,9 +138,12 @@ export default {
update: (store, { data: { UpdateUser } }) => {
const { name, locationName, about } = UpdateUser
this.form = { name, locationName, about }
// update the user menu, too
// which listens on auth/user
this.$store.dispatch('auth/fetchCurrentUser')
this.currentUser = {
...this.currentUser,
name,
locationName,
about
}
}
})
.then(data => {