diff --git a/src/actions/LocalStorageActions.js b/src/actions/LocalStorageActions.js index 3fed5c65..5cb91059 100644 --- a/src/actions/LocalStorageActions.js +++ b/src/actions/LocalStorageActions.js @@ -52,6 +52,7 @@ const KEY_DISCOVERY: string = `${STORAGE_PATH}discovery`; const KEY_TOKENS: string = `${STORAGE_PATH}tokens`; const KEY_PENDING: string = `${STORAGE_PATH}pending`; const KEY_BETA_MODAL: string = '/betaModalPrivacy'; // this key needs to be compatible with "parent" (old) wallet +const KEY_LANGUAGE: string = `${STORAGE_PATH}language`; // https://github.com/STRML/react-localstorage/blob/master/react-localstorage.js // or @@ -235,6 +236,14 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { }); } } + + const language: ?string = storageUtils.get(TYPE, KEY_LANGUAGE); + if (language) { + dispatch({ + type: WALLET.SET_LANGUAGE, + language: JSON.parse(language), + }); + } }; export const loadData = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { @@ -250,3 +259,8 @@ export const hideBetaDisclaimer = (): ThunkAction => (dispatch: Dispatch): void storageUtils.set(TYPE, KEY_BETA_MODAL, true); dispatch(loadJSON()); }; + +export const setLanguage = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { + const { language } = getState().wallet; + storageUtils.set(TYPE, KEY_LANGUAGE, JSON.stringify(language)); +}; diff --git a/src/services/LocalStorageService.js b/src/services/LocalStorageService.js index 7719120e..98d8852b 100644 --- a/src/services/LocalStorageService.js +++ b/src/services/LocalStorageService.js @@ -25,6 +25,10 @@ const LocalStorageService: Middleware = (api: MiddlewareAPI) => (next: Middlewar case WALLET.HIDE_BETA_DISCLAIMER: api.dispatch(LocalStorageActions.hideBetaDisclaimer()); break; + + case WALLET.SET_LANGUAGE: + api.dispatch(LocalStorageActions.setLanguage()); + break; // first time saving case CONNECT.REMEMBER: api.dispatch(LocalStorageActions.save());