mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
- write tests for userMiddleware - checks the functionality of nodes/locations middleware - refactor to not allow users to update to remove their name debatable whether we want that or not, but we do not allow users to create accounts with no name, so we should be consistent, before we were using neode to validate this, but we have are removing neode from production code, so we must validate ourselves - collate UpdateUser mutations to one
61 lines
1.6 KiB
Vue
61 lines
1.6 KiB
Vue
<template>
|
|
<ds-card :header="$t('settings.privacy.name')">
|
|
<ds-space margin-bottom="small">
|
|
<input id="allow-shouts" type="checkbox" v-model="shoutsAllowed" />
|
|
<label for="allow-shouts">{{ $t('settings.privacy.make-shouts-public') }}</label>
|
|
</ds-space>
|
|
<ds-button primary @click="submit" :disabled="disabled">{{ $t('actions.save') }}</ds-button>
|
|
</ds-card>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters, mapMutations } from 'vuex'
|
|
import { updateUserMutation } from '~/graphql/User'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
shoutsAllowed: false,
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters({
|
|
currentUser: 'auth/user',
|
|
}),
|
|
disabled() {
|
|
return this.shoutsAllowed === this.currentUser.showShoutsPublicly
|
|
},
|
|
},
|
|
created() {
|
|
this.shoutsAllowed = this.currentUser.showShoutsPublicly || false
|
|
},
|
|
methods: {
|
|
...mapMutations({
|
|
setCurrentUser: 'auth/SET_USER',
|
|
}),
|
|
async submit() {
|
|
try {
|
|
await this.$apollo.mutate({
|
|
mutation: updateUserMutation(),
|
|
variables: {
|
|
id: this.currentUser.id,
|
|
name: this.currentUser.name,
|
|
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)
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|