fix: Help Center articles are not available on the widget [CW-2534] (#7954)

This commit is contained in:
Nithin David Thomas
2023-09-21 17:06:15 +05:30
committed by GitHub
parent bdeb2f9812
commit fabb3c8da4
6 changed files with 48 additions and 2 deletions

View File

@@ -68,6 +68,7 @@ export default {
unreadMessageCount: 'conversation/getUnreadMessageCount',
popularArticles: 'article/popularArticles',
articleUiFlags: 'article/uiFlags',
widgetLocale: 'appConfig/widgetLocale',
}),
portal() {
return window.chatwootWebChannel.portal;
@@ -79,12 +80,28 @@ export default {
this.popularArticles.length
);
},
defaultLocale() {
const widgetLocale = this.widgetLocale;
const {
allowed_locales: allowedLocales,
default_locale: defaultLocale,
} = this.portal.config;
// IMPORTANT: Variation strict locale matching, Follow iso_639_1_code
// If the exact match of a locale is available in the list of portal locales, return it
// Else return the default locale. Eg: `es` will not work if `es_ES` is available in the list
if (allowedLocales.includes(widgetLocale)) {
return widgetLocale;
}
return defaultLocale;
},
},
mounted() {
if (this.portal && this.popularArticles.length === 0) {
const locale = this.defaultLocale;
this.$store.dispatch('article/fetch', {
slug: this.portal.slug,
locale: 'en',
locale,
});
}
},
@@ -102,9 +119,9 @@ export default {
});
},
viewAllArticles() {
const locale = this.defaultLocale;
const {
portal: { slug },
locale = 'en',
} = window.chatwootWebChannel;
this.openArticleInArticleViewer(`/hc/${slug}/${locale}`);
},