mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
run update mutation when submitting shouts form
This commit is contained in:
parent
feb65a6c9c
commit
1625e0705e
@ -238,7 +238,8 @@
|
|||||||
},
|
},
|
||||||
"privacy": {
|
"privacy": {
|
||||||
"name": "Privatsphäre",
|
"name": "Privatsphäre",
|
||||||
"make-shouts-public": "Teile von mir empfohlene Artikel öffentlich auf meinem Profil"
|
"make-shouts-public": "Teile von mir empfohlene Artikel öffentlich auf meinem Profil",
|
||||||
|
"success-update": "Privatsphäre-Einstellungen gespeichert"
|
||||||
},
|
},
|
||||||
"invites": {
|
"invites": {
|
||||||
"name": "Einladungen"
|
"name": "Einladungen"
|
||||||
|
|||||||
@ -239,7 +239,8 @@
|
|||||||
},
|
},
|
||||||
"privacy": {
|
"privacy": {
|
||||||
"name": "Privacy",
|
"name": "Privacy",
|
||||||
"make-shouts-public": "Share articles I have shouted on my public profile"
|
"make-shouts-public": "Share articles I have shouted on my public profile",
|
||||||
|
"success-update": "Privacy settings saved"
|
||||||
},
|
},
|
||||||
"invites": {
|
"invites": {
|
||||||
"name": "Invites"
|
"name": "Invites"
|
||||||
|
|||||||
@ -4,30 +4,55 @@
|
|||||||
<input id="allow-shouts" type="checkbox" v-model="shoutsAllowed" />
|
<input id="allow-shouts" type="checkbox" v-model="shoutsAllowed" />
|
||||||
<label for="allow-shouts">{{ $t('settings.privacy.make-shouts-public') }}</label>
|
<label for="allow-shouts">{{ $t('settings.privacy.make-shouts-public') }}</label>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
<ds-button primary @click="submit">{{ $t('actions.save') }}</ds-button>
|
<ds-button primary @click="submit" :disabled="disabled">{{ $t('actions.save') }}</ds-button>
|
||||||
</ds-card>
|
</ds-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
|
import { showShoutsPubliclyMutation } from '~/graphql/User'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
shoutsAllowed: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
currentUser: 'auth/user',
|
currentUser: 'auth/user',
|
||||||
}),
|
}),
|
||||||
shoutsAllowed: {
|
disabled() {
|
||||||
get() {
|
return this.shoutsAllowed === this.currentUser.showShoutsPublicly
|
||||||
return this.currentUser.shoutsAllowed || false
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
return value
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.shoutsAllowed = this.currentUser.showShoutsPublicly || false
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit() {
|
...mapMutations({
|
||||||
console.log('wohoo')
|
setCurrentUser: 'auth/SET_USER',
|
||||||
|
}),
|
||||||
|
async submit() {
|
||||||
|
try {
|
||||||
|
await this.$apollo.mutate({
|
||||||
|
mutation: showShoutsPubliclyMutation(),
|
||||||
|
variables: {
|
||||||
|
id: this.currentUser.id,
|
||||||
|
showShoutsPublicly: this.shoutsAllowed,
|
||||||
|
},
|
||||||
|
update: (_, { data: { UpdateUser } }) => {
|
||||||
|
const { showShoutsPublicly } = UpdateUser
|
||||||
|
this.setCurrentUser({
|
||||||
|
...this.currentUser,
|
||||||
|
showShoutsPublicly,
|
||||||
|
})
|
||||||
|
this.$toast.success(this.$t('settings.privacy.success-update'))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
this.$toast.error(error.message)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user