Streaming: Add locale fallback for invalid locale
This commit is contained in:
parent
6652df35b3
commit
e7bd011495
1 changed files with 8 additions and 1 deletions
|
@ -12,10 +12,17 @@ import { fetchFilters } from './filters';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
import messages from 'soapbox/locales/messages';
|
import messages from 'soapbox/locales/messages';
|
||||||
|
|
||||||
|
const validLocale = locale => Object.keys(messages).includes(locale);
|
||||||
|
|
||||||
|
const getLocale = state => {
|
||||||
|
const locale = getSettings(state).get('locale');
|
||||||
|
return validLocale(locale) ? locale : 'en';
|
||||||
|
};
|
||||||
|
|
||||||
export function connectTimelineStream(timelineId, path, pollingRefresh = null, accept = null) {
|
export function connectTimelineStream(timelineId, path, pollingRefresh = null, accept = null) {
|
||||||
|
|
||||||
return connectStream (path, pollingRefresh, (dispatch, getState) => {
|
return connectStream (path, pollingRefresh, (dispatch, getState) => {
|
||||||
const locale = getSettings(getState()).get('locale');
|
const locale = getLocale(getState());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onConnect() {
|
onConnect() {
|
||||||
|
|
Loading…
Reference in a new issue