diff --git a/app/javascript/widget/App.vue b/app/javascript/widget/App.vue index 3d154dd03..3c218266a 100755 --- a/app/javascript/widget/App.vue +++ b/app/javascript/widget/App.vue @@ -111,7 +111,6 @@ export default { 'setWidgetColor', 'setBubbleVisibility', 'setColorScheme', - 'setLocale', ]), ...mapActions('conversation', ['fetchOldConversations', 'setUserLastSeen']), ...mapActions('campaign', [ @@ -153,10 +152,8 @@ export default { if (hasLocaleWithVariation) { this.$root.$i18n.locale = localeWithVariation; - this.$store.dispatch('appConfig/setLocale', localeWithVariation); } else if (hasLocaleWithoutVariation) { this.$root.$i18n.locale = localeWithoutVariation; - this.$store.dispatch('appConfig/setLocale', localeWithoutVariation); } }, registerUnreadEvents() { diff --git a/app/javascript/widget/store/modules/appConfig.js b/app/javascript/widget/store/modules/appConfig.js index a51bd1ad3..b1b67f0dc 100644 --- a/app/javascript/widget/store/modules/appConfig.js +++ b/app/javascript/widget/store/modules/appConfig.js @@ -5,7 +5,6 @@ import { SET_WIDGET_APP_CONFIG, SET_WIDGET_COLOR, TOGGLE_WIDGET_OPEN, - SET_WIDGET_LOCALE, } from '../types'; const state = { @@ -19,7 +18,6 @@ const state = { widgetColor: '', widgetStyle: 'standard', darkMode: 'light', - locale: 'en', }; export const getters = { @@ -31,7 +29,6 @@ export const getters = { getReferrerHost: $state => $state.referrerHost, isWidgetStyleFlat: $state => $state.widgetStyle === 'flat', darkMode: $state => $state.darkMode, - widgetLocale: $state => $state.locale, }; export const actions = { @@ -68,9 +65,6 @@ export const actions = { setBubbleVisibility({ commit }, hideMessageBubble) { commit(SET_BUBBLE_VISIBILITY, hideMessageBubble); }, - setLocale({ commit }, locale) { - commit(SET_WIDGET_LOCALE, locale); - }, }; export const mutations = { @@ -97,9 +91,6 @@ export const mutations = { [SET_COLOR_SCHEME]($state, darkMode) { $state.darkMode = darkMode; }, - [SET_WIDGET_LOCALE]($state, locale) { - $state.locale = locale || $state.locale; - }, }; export default { diff --git a/app/javascript/widget/store/modules/specs/appConfig/actions.spec.js b/app/javascript/widget/store/modules/specs/appConfig/actions.spec.js index 80dcc24b2..89aea11a0 100644 --- a/app/javascript/widget/store/modules/specs/appConfig/actions.spec.js +++ b/app/javascript/widget/store/modules/specs/appConfig/actions.spec.js @@ -31,11 +31,4 @@ describe('#actions', () => { expect(commit.mock.calls).toEqual([['SET_COLOR_SCHEME', 'dark']]); }); }); - - describe('#setLocale', () => { - it('creates actions for setting the locale properly', () => { - actions.setLocale({ commit }, 'es_ES'); - expect(commit.mock.calls).toEqual([['SET_WIDGET_LOCALE', 'es_ES']]); - }); - }); }); diff --git a/app/javascript/widget/store/modules/specs/appConfig/mutations.spec.js b/app/javascript/widget/store/modules/specs/appConfig/mutations.spec.js index caad5ce80..e79235e28 100644 --- a/app/javascript/widget/store/modules/specs/appConfig/mutations.spec.js +++ b/app/javascript/widget/store/modules/specs/appConfig/mutations.spec.js @@ -32,12 +32,4 @@ describe('#mutations', () => { expect(state.darkMode).toEqual('dark'); }); }); - - describe('#SET_WIDGET_LOCALE', () => { - it('sets widget locale properly', () => { - const state = { locale: 'en' }; - mutations.SET_WIDGET_LOCALE(state, 'es_ES'); - expect(state.locale).toEqual('es_ES'); - }); - }); }); diff --git a/app/javascript/widget/store/types.js b/app/javascript/widget/store/types.js index edbb25ce1..17398b682 100644 --- a/app/javascript/widget/store/types.js +++ b/app/javascript/widget/store/types.js @@ -7,4 +7,3 @@ export const UPDATE_CONVERSATION_ATTRIBUTES = 'UPDATE_CONVERSATION_ATTRIBUTES'; export const TOGGLE_WIDGET_OPEN = 'TOGGLE_WIDGET_OPEN'; export const SET_REFERRER_HOST = 'SET_REFERRER_HOST'; export const SET_BUBBLE_VISIBILITY = 'SET_BUBBLE_VISIBILITY'; -export const SET_WIDGET_LOCALE = 'SET_WIDGET_LOCALE'; diff --git a/app/javascript/widget/views/Home.vue b/app/javascript/widget/views/Home.vue index c5fd41960..3625f88f4 100755 --- a/app/javascript/widget/views/Home.vue +++ b/app/javascript/widget/views/Home.vue @@ -68,8 +68,10 @@ export default { unreadMessageCount: 'conversation/getUnreadMessageCount', popularArticles: 'article/popularArticles', articleUiFlags: 'article/uiFlags', - widgetLocale: 'appConfig/widgetLocale', }), + widgetLocale() { + return this.$i18n.locale || 'en'; + }, portal() { return window.chatwootWebChannel.portal; },