mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Refactor to consolidate UpdateUser mutations
This commit is contained in:
parent
d375ebe7d9
commit
fd1e2c91fd
@ -33,12 +33,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import Dropdown from '~/components/Dropdown'
|
||||
import find from 'lodash/find'
|
||||
import orderBy from 'lodash/orderBy'
|
||||
import locales from '~/locales'
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import { updateUserMutation } from '~/graphql/User.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -87,16 +87,10 @@ export default {
|
||||
if (!this.currentUser || !this.currentUser.id) return null
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: gql`
|
||||
mutation($id: ID!, $locale: String) {
|
||||
UpdateUser(id: $id, locale: $locale) {
|
||||
id
|
||||
locale
|
||||
}
|
||||
}
|
||||
`,
|
||||
mutation: updateUserMutation(),
|
||||
variables: {
|
||||
id: this.currentUser.id,
|
||||
name: this.currentUser.name,
|
||||
locale: this.$i18n.locale(),
|
||||
},
|
||||
update: (store, { data: { UpdateUser } }) => {
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import vueDropzone from 'nuxt-dropzone'
|
||||
import gql from 'graphql-tag'
|
||||
import { updateUserMutation } from '~/graphql/User.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -62,17 +62,11 @@ export default {
|
||||
const avatarUpload = file[0]
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: gql`
|
||||
mutation($id: ID!, $avatarUpload: Upload) {
|
||||
UpdateUser(id: $id, avatarUpload: $avatarUpload) {
|
||||
id
|
||||
avatar
|
||||
}
|
||||
}
|
||||
`,
|
||||
mutation: updateUserMutation(),
|
||||
variables: {
|
||||
avatarUpload,
|
||||
id: this.user.id,
|
||||
name: this.user.name,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
@ -149,7 +149,10 @@ export const updateUserMutation = () => {
|
||||
$locationName: String
|
||||
$about: String
|
||||
$allowEmbedIframes: Boolean
|
||||
$showShoutsPublicly: Boolean
|
||||
$locale: String
|
||||
$termsAndConditionsAgreedVersion: String
|
||||
$avatarUpload: Upload
|
||||
) {
|
||||
UpdateUser(
|
||||
id: $id
|
||||
@ -160,6 +163,8 @@ export const updateUserMutation = () => {
|
||||
allowEmbedIframes: $allowEmbedIframes
|
||||
showShoutsPublicly: $showShoutsPublicly
|
||||
locale: $locale
|
||||
termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion
|
||||
avatarUpload: $avatarUpload
|
||||
) {
|
||||
id
|
||||
slug
|
||||
@ -169,6 +174,8 @@ export const updateUserMutation = () => {
|
||||
allowEmbedIframes
|
||||
showShoutsPublicly
|
||||
locale
|
||||
termsAndConditionsAgreedVersion
|
||||
avatar
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@ -24,17 +24,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import { VERSION } from '~/constants/terms-and-conditions-version.js'
|
||||
const mutation = gql`
|
||||
mutation($id: ID!, $termsAndConditionsAgreedVersion: String) {
|
||||
UpdateUser(id: $id, termsAndConditionsAgreedVersion: $termsAndConditionsAgreedVersion) {
|
||||
id
|
||||
termsAndConditionsAgreedVersion
|
||||
}
|
||||
}
|
||||
`
|
||||
import { updateUserMutation } from '~/graphql/User.js'
|
||||
|
||||
export default {
|
||||
layout: 'default',
|
||||
head() {
|
||||
@ -74,9 +67,10 @@ export default {
|
||||
async submit() {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation,
|
||||
mutation: updateUserMutation(),
|
||||
variables: {
|
||||
id: this.currentUser.id,
|
||||
name: this.currentUser.name,
|
||||
termsAndConditionsAgreedVersion: VERSION,
|
||||
},
|
||||
update: (store, { data: { UpdateUser } }) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user