Allow only valid locales
This commit is contained in:
parent
7e16536d70
commit
082d3f1121
1 changed files with 4 additions and 1 deletions
|
@ -25,6 +25,8 @@ import { getSettings } from 'soapbox/actions/settings';
|
||||||
import { generateThemeCss } from 'soapbox/utils/theme';
|
import { generateThemeCss } from 'soapbox/utils/theme';
|
||||||
import messages from 'soapbox/locales/messages';
|
import messages from 'soapbox/locales/messages';
|
||||||
|
|
||||||
|
const validLocale = locale => Object.keys(messages).includes(locale);
|
||||||
|
|
||||||
export const store = configureStore();
|
export const store = configureStore();
|
||||||
const hydrateAction = hydrateStore(initialState);
|
const hydrateAction = hydrateStore(initialState);
|
||||||
|
|
||||||
|
@ -39,6 +41,7 @@ const mapStateToProps = (state) => {
|
||||||
const account = state.getIn(['accounts', me]);
|
const account = state.getIn(['accounts', me]);
|
||||||
const showIntroduction = account ? state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION : false;
|
const showIntroduction = account ? state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION : false;
|
||||||
const settings = getSettings(state);
|
const settings = getSettings(state);
|
||||||
|
const locale = settings.get('locale');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showIntroduction,
|
showIntroduction,
|
||||||
|
@ -47,7 +50,7 @@ const mapStateToProps = (state) => {
|
||||||
systemFont: settings.get('systemFont'),
|
systemFont: settings.get('systemFont'),
|
||||||
dyslexicFont: settings.get('dyslexicFont'),
|
dyslexicFont: settings.get('dyslexicFont'),
|
||||||
demetricator: settings.get('demetricator'),
|
demetricator: settings.get('demetricator'),
|
||||||
locale: settings.get('locale'),
|
locale: validLocale(locale) ? locale : 'en',
|
||||||
themeCss: generateThemeCss(state.getIn(['soapbox', 'brandColor'])),
|
themeCss: generateThemeCss(state.getIn(['soapbox', 'brandColor'])),
|
||||||
themeMode: settings.get('themeMode'),
|
themeMode: settings.get('themeMode'),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue