mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
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:
parent
ea9f896ef8
commit
41072e6fa8
@ -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 => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user