Update currentUser after successful addSocialMedia mutation

Co-authored-by: Mike Aono <aonomike@gmail.com>
This commit is contained in:
Matt Rider 2019-03-28 15:54:45 -03:00
parent 78ec42e000
commit 94288ced54

View File

@ -13,7 +13,9 @@
<a :href="link.url">
<img
:src="link.favicon"
alt=""
alt="Social Media link"
width="16"
height="16"
>
{{ link.url }}
</a>
@ -42,7 +44,7 @@
</template>
<script>
import gql from 'graphql-tag'
import { mapGetters } from 'vuex'
import { mapGetters, mapMutations } from 'vuex'
export default {
data() {
@ -67,6 +69,9 @@ export default {
}
},
methods: {
...mapMutations({
setCurrentUser: 'auth/SET_USER'
}),
handleAddSocialMedia() {
this.$apollo
.mutate({
@ -77,9 +82,19 @@ export default {
`,
variables: {
url: this.value
},
update: (store, { data }) => {
const socialMedia = data.addSocialMedia
this.setCurrentUser({
...this.currentUser,
socialMedia
})
}
})
.then(this.$toast.success(this.$t('settings.social-media.success')))
.then(
this.$toast.success(this.$t('settings.social-media.success')),
(this.value = '')
)
}
}
}