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 assets assets
|
||||||
COPY components/LocaleSwitch/ components/LocaleSwitch
|
COPY components/LocaleSwitch/ components/LocaleSwitch
|
||||||
COPY graphql graphql
|
|
||||||
COPY components/Dropdown.vue components/Dropdown.vue
|
COPY components/Dropdown.vue components/Dropdown.vue
|
||||||
COPY layouts/blank.vue layouts/blank.vue
|
COPY layouts/blank.vue layouts/blank.vue
|
||||||
COPY locales locales
|
COPY locales locales
|
||||||
|
|||||||
@ -33,12 +33,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import gql from 'graphql-tag'
|
||||||
import Dropdown from '~/components/Dropdown'
|
import Dropdown from '~/components/Dropdown'
|
||||||
import find from 'lodash/find'
|
import find from 'lodash/find'
|
||||||
import orderBy from 'lodash/orderBy'
|
import orderBy from 'lodash/orderBy'
|
||||||
import locales from '~/locales'
|
import locales from '~/locales'
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import { localeMutation } from '~/graphql/User.js'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -84,9 +84,17 @@ export default {
|
|||||||
setCurrentUser: 'auth/SET_USER',
|
setCurrentUser: 'auth/SET_USER',
|
||||||
}),
|
}),
|
||||||
async updateUserLocale() {
|
async updateUserLocale() {
|
||||||
|
if (!this.currentUser || !this.currentUser.id) return null
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: localeMutation(),
|
mutation: gql`
|
||||||
|
mutation($id: ID!, $locale: String) {
|
||||||
|
UpdateUser(id: $id, locale: $locale) {
|
||||||
|
id
|
||||||
|
locale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
variables: {
|
variables: {
|
||||||
id: this.currentUser.id,
|
id: this.currentUser.id,
|
||||||
locale: this.$i18n.locale(),
|
locale: this.$i18n.locale(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user