Streaming: Add locale fallback for invalid locale

timeline-tab-hover-styles
Alex Gleason 2020-08-13 04:20:35 -05:00
rodzic 6652df35b3
commit e7bd011495
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -12,10 +12,17 @@ import { fetchFilters } from './filters';
import { getSettings } from 'soapbox/actions/settings';
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) {
return connectStream (path, pollingRefresh, (dispatch, getState) => {
const locale = getSettings(getState()).get('locale');
const locale = getLocale(getState());
return {
onConnect() {