From d39de3022108c4a42d20fe2a38265179ae0062f9 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Sat, 26 Mar 2022 12:39:26 -0400 Subject: Add config opts for email language --- src/components/settings_modal/tabs/profile_tab.js | 38 ++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src/components/settings_modal/tabs/profile_tab.js') diff --git a/src/components/settings_modal/tabs/profile_tab.js b/src/components/settings_modal/tabs/profile_tab.js index bee8a7bb..953f17f0 100644 --- a/src/components/settings_modal/tabs/profile_tab.js +++ b/src/components/settings_modal/tabs/profile_tab.js @@ -8,8 +8,10 @@ import EmojiInput from 'src/components/emoji_input/emoji_input.vue' import suggestor from 'src/components/emoji_input/suggestor.js' import Autosuggest from 'src/components/autosuggest/autosuggest.vue' import Checkbox from 'src/components/checkbox/checkbox.vue' +import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue' import BooleanSetting from '../helpers/boolean_setting.vue' import SharedComputedObject from '../helpers/shared_computed_object.js' +import localeService from 'src/services/locale/locale.service.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -40,7 +42,8 @@ const ProfileTab = { banner: null, bannerPreview: null, background: null, - backgroundPreview: null + backgroundPreview: null, + emailLanguage: this.$store.state.users.currentUser.language } }, components: { @@ -50,7 +53,8 @@ const ProfileTab = { Autosuggest, ProgressButton, Checkbox, - BooleanSetting + BooleanSetting, + InterfaceLanguageSwitcher }, computed: { user () { @@ -111,19 +115,25 @@ const ProfileTab = { }, methods: { updateProfile () { + const params = { + note: this.newBio, + locked: this.newLocked, + // Backend notation. + /* eslint-disable camelcase */ + display_name: this.newName, + fields_attributes: this.newFields.filter(el => el != null), + bot: this.bot, + show_role: this.showRole, + /* eslint-enable camelcase */ + } + + if (this.emailLanguage) { + params.language = localeService.internalToBackendLocale(this.emailLanguage) + } + this.$store.state.api.backendInteractor - .updateProfile({ - params: { - note: this.newBio, - locked: this.newLocked, - // Backend notation. - /* eslint-disable camelcase */ - display_name: this.newName, - fields_attributes: this.newFields.filter(el => el != null), - bot: this.bot, - show_role: this.showRole - /* eslint-enable camelcase */ - } }).then((user) => { + .updateProfile({ params }) + .then((user) => { this.newFields.splice(user.fields.length) merge(this.newFields, user.fields) this.$store.commit('addNewUsers', [user]) -- cgit v1.2.3-70-g09d2 From 3633ea66d4c6f362510788f3ae7ae4cad020629a Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Sat, 26 Mar 2022 13:08:22 -0400 Subject: Make lint happy --- src/components/registration/registration.js | 2 +- src/components/settings_modal/tabs/profile_tab.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/components/settings_modal/tabs/profile_tab.js') diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index e3f6b875..6eb316d0 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -14,7 +14,7 @@ const registration = { password: '', confirm: '', reason: '', - language: '', + language: '' }, captcha: {} }), diff --git a/src/components/settings_modal/tabs/profile_tab.js b/src/components/settings_modal/tabs/profile_tab.js index 953f17f0..9a8628f0 100644 --- a/src/components/settings_modal/tabs/profile_tab.js +++ b/src/components/settings_modal/tabs/profile_tab.js @@ -43,7 +43,7 @@ const ProfileTab = { bannerPreview: null, background: null, backgroundPreview: null, - emailLanguage: this.$store.state.users.currentUser.language + emailLanguage: this.$store.state.users.currentUser.language || '' } }, components: { @@ -123,7 +123,7 @@ const ProfileTab = { display_name: this.newName, fields_attributes: this.newFields.filter(el => el != null), bot: this.bot, - show_role: this.showRole, + show_role: this.showRole /* eslint-enable camelcase */ } -- cgit v1.2.3-70-g09d2