mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Update LocaleSwitch with guard clause
- return if there is no currentUser - do not copy graphql directory as there is no need to send messages to backend
This commit is contained in:
parent
9d522353cc
commit
821ea6d671
@ -19,7 +19,6 @@ RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
|
||||
COPY assets assets
|
||||
COPY components/LocaleSwitch/ components/LocaleSwitch
|
||||
COPY graphql graphql
|
||||
COPY components/Dropdown.vue components/Dropdown.vue
|
||||
COPY layouts/blank.vue layouts/blank.vue
|
||||
COPY locales locales
|
||||
|
||||
@ -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 { localeMutation } from '~/graphql/User.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -84,9 +84,17 @@ export default {
|
||||
setCurrentUser: 'auth/SET_USER',
|
||||
}),
|
||||
async updateUserLocale() {
|
||||
if (!this.currentUser || !this.currentUser.id) return null
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: localeMutation(),
|
||||
mutation: gql`
|
||||
mutation($id: ID!, $locale: String) {
|
||||
UpdateUser(id: $id, locale: $locale) {
|
||||
id
|
||||
locale
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: this.currentUser.id,
|
||||
locale: this.$i18n.locale(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user