From e7bd011495d3f4f4f75ac2ce6aa27258973b1186 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 13 Aug 2020 04:20:35 -0500 Subject: [PATCH] Streaming: Add locale fallback for invalid locale --- app/soapbox/actions/streaming.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/soapbox/actions/streaming.js b/app/soapbox/actions/streaming.js index ef515798a..027491a1c 100644 --- a/app/soapbox/actions/streaming.js +++ b/app/soapbox/actions/streaming.js @@ -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() {