mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-27 18:58:08 +00:00
save selected language to local storage
This commit is contained in:
parent
ddf2819de3
commit
e2ccb31532
@ -52,6 +52,7 @@ const KEY_DISCOVERY: string = `${STORAGE_PATH}discovery`;
|
|||||||
const KEY_TOKENS: string = `${STORAGE_PATH}tokens`;
|
const KEY_TOKENS: string = `${STORAGE_PATH}tokens`;
|
||||||
const KEY_PENDING: string = `${STORAGE_PATH}pending`;
|
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_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
|
// https://github.com/STRML/react-localstorage/blob/master/react-localstorage.js
|
||||||
// or
|
// 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 => {
|
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);
|
storageUtils.set(TYPE, KEY_BETA_MODAL, true);
|
||||||
dispatch(loadJSON());
|
dispatch(loadJSON());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setLanguage = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
const { language } = getState().wallet;
|
||||||
|
storageUtils.set(TYPE, KEY_LANGUAGE, JSON.stringify(language));
|
||||||
|
};
|
||||||
|
@ -25,6 +25,10 @@ const LocalStorageService: Middleware = (api: MiddlewareAPI) => (next: Middlewar
|
|||||||
case WALLET.HIDE_BETA_DISCLAIMER:
|
case WALLET.HIDE_BETA_DISCLAIMER:
|
||||||
api.dispatch(LocalStorageActions.hideBetaDisclaimer());
|
api.dispatch(LocalStorageActions.hideBetaDisclaimer());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WALLET.SET_LANGUAGE:
|
||||||
|
api.dispatch(LocalStorageActions.setLanguage());
|
||||||
|
break;
|
||||||
// first time saving
|
// first time saving
|
||||||
case CONNECT.REMEMBER:
|
case CONNECT.REMEMBER:
|
||||||
api.dispatch(LocalStorageActions.save());
|
api.dispatch(LocalStorageActions.save());
|
||||||
|
Loading…
Reference in New Issue
Block a user