From 96e1d3b8428fc8514814a8d37e9c60cda470c0ee Mon Sep 17 00:00:00 2001 From: tomivm Date: Thu, 24 Mar 2022 10:26:30 -0300 Subject: [PATCH] add langsFetched to blacklist --- .../Settings/Language/Language.container.js | 6 +++--- .../LanguageProvider/LanguageProvider.actions.js | 7 ------- .../LanguageProvider/LanguageProvider.constants.js | 2 -- .../LanguageProvider/LanguageProvider.reducer.js | 6 ------ .../SpeechProvider/SpeechProvider.container.js | 9 +-------- src/reducers.js | 13 ++++++++++--- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/components/Settings/Language/Language.container.js b/src/components/Settings/Language/Language.container.js index b0a2b13df..245215978 100644 --- a/src/components/Settings/Language/Language.container.js +++ b/src/components/Settings/Language/Language.container.js @@ -445,14 +445,14 @@ export class LanguageContainer extends Component { const downloadingLangState = { isdownloading: false }; + setDownloadingLang(downloadingLangState); this.setState({ downloadingLangError: { ttsError: false, langError: false - } + }, + selectedLang: selectedLang }); - setDownloadingLang(downloadingLangState); - this.setState({ selectedLang: selectedLang }); this.refreshLanguageList(); if (isDiferentTts) return; await this.handleSubmit(selectedLang); diff --git a/src/providers/LanguageProvider/LanguageProvider.actions.js b/src/providers/LanguageProvider/LanguageProvider.actions.js index fbbb72709..399629565 100644 --- a/src/providers/LanguageProvider/LanguageProvider.actions.js +++ b/src/providers/LanguageProvider/LanguageProvider.actions.js @@ -1,6 +1,5 @@ import { CHANGE_LANG, - START_FETCHING_LANGS, SET_LANGS, SET_DOWNLOADING_LANG } from './LanguageProvider.constants'; @@ -14,12 +13,6 @@ export function changeLang(lang) { }; } -export function startFetchingLangs() { - return { - type: START_FETCHING_LANGS - }; -} - export function setLangs(langs, localLangs) { return { type: SET_LANGS, diff --git a/src/providers/LanguageProvider/LanguageProvider.constants.js b/src/providers/LanguageProvider/LanguageProvider.constants.js index f147df237..5657372d5 100644 --- a/src/providers/LanguageProvider/LanguageProvider.constants.js +++ b/src/providers/LanguageProvider/LanguageProvider.constants.js @@ -1,6 +1,4 @@ export const CHANGE_LANG = 'cboard/LanguageProvider/CHANGE_LANG'; -export const START_FETCHING_LANGS = - 'cboard/LanguageProvider/START_FETCHING_LANGS'; export const SET_LANGS = 'cboard/LanguageProvider/SET_LANGS'; export const SET_DOWNLOADING_LANG = 'cboard/LanguageProvider/SET_DOWNLOADING_LANG'; diff --git a/src/providers/LanguageProvider/LanguageProvider.reducer.js b/src/providers/LanguageProvider/LanguageProvider.reducer.js index 8bdf89b16..68a17418d 100644 --- a/src/providers/LanguageProvider/LanguageProvider.reducer.js +++ b/src/providers/LanguageProvider/LanguageProvider.reducer.js @@ -1,6 +1,5 @@ import { CHANGE_LANG, - START_FETCHING_LANGS, SET_LANGS, SET_DOWNLOADING_LANG } from './LanguageProvider.constants'; @@ -42,11 +41,6 @@ function languageProviderReducer(state = initialState, action) { lang: action.lang ? action.lang : state.lang, dir: action.lang ? getDir(action.lang) : state.dir }; - case START_FETCHING_LANGS: - return { - ...state, - langsFetched: false - }; case SET_LANGS: return { ...state, diff --git a/src/providers/SpeechProvider/SpeechProvider.container.js b/src/providers/SpeechProvider/SpeechProvider.container.js index f476b64dd..15778fa9c 100644 --- a/src/providers/SpeechProvider/SpeechProvider.container.js +++ b/src/providers/SpeechProvider/SpeechProvider.container.js @@ -10,7 +10,6 @@ import { updateLangSpeechStatus, setTtsEngine } from './SpeechProvider.actions'; -import { startFetchingLangs } from '../LanguageProvider/LanguageProvider.actions'; import { isAndroid } from '../../cordova-util'; export class SpeechProvider extends Component { @@ -20,11 +19,6 @@ export class SpeechProvider extends Component { setTtsEngine: PropTypes.func }; - constructor(props) { - super(props); - this.props.startFetchingLangs(); - } - async componentDidMount() { const { getVoices, @@ -73,8 +67,7 @@ const mapDispatchToProps = { getTtsEngines, getTtsDefaultEngine, setTtsEngine, - updateLangSpeechStatus, - startFetchingLangs + updateLangSpeechStatus }; export default connect( diff --git a/src/reducers.js b/src/reducers.js index c30c9acad..47621ad32 100644 --- a/src/reducers.js +++ b/src/reducers.js @@ -1,4 +1,4 @@ -import { persistCombineReducers } from 'redux-persist'; +import { persistCombineReducers, persistReducer } from 'redux-persist'; import appReducer from './components/App/App.reducer'; import languageProviderReducer from './providers/LanguageProvider/LanguageProvider.reducer'; @@ -11,13 +11,20 @@ import storage from 'redux-persist/lib/storage'; const config = { key: 'root', - storage + storage, + blacklist: ['language'] +}; + +const languagePersistConfig = { + key: 'language', + storage: storage, + blacklist: ['langsFetched'] }; export default function createReducer() { return persistCombineReducers(config, { app: appReducer, - language: languageProviderReducer, + language: persistReducer(languagePersistConfig, languageProviderReducer), speech: speechProviderReducer, board: boardReducer, communicator: communicatorReducer,