diff --git a/app/frontend/actions.ts b/app/frontend/actions.ts index 18ebbef0ff..59cc568f58 100644 --- a/app/frontend/actions.ts +++ b/app/frontend/actions.ts @@ -30,6 +30,7 @@ import CryptoProviderFactory from './wallet/byron/crypto-provider-factory' import ShelleyCryptoProviderFactory from './wallet/shelley/shelley-crypto-provider-factory' import {ShelleyWallet} from './wallet/shelley-wallet' import getDonationAddress from './helpers/getDonationAddress' +import {localStorageVars} from './localStorage' let wallet: ReturnType @@ -1091,7 +1092,7 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF const closeWelcome = (state, dontShowDisclaimer) => { // we may get an ignored click event as the second argument, check only against booleans - window.localStorage.setItem('dontShowDisclaimer', dontShowDisclaimer) + window.localStorage.setItem(localStorageVars.WELCOME, dontShowDisclaimer) setState({ displayWelcome: false, }) @@ -1103,23 +1104,23 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF }) } - const closeInfoModal = (state, dontShowDisclaimer) => { + const closeInfoModal = (state, dontShowInfoModal) => { // we may get an ignored click event as the second argument, check only against booleans - window.localStorage.setItem('dontShowInfoModal', dontShowDisclaimer) + window.localStorage.setItem(localStorageVars.INFO_MODAL, dontShowInfoModal) setState({ displayInfoModal: false, }) } const closeStakingBanner = (state) => { - window.localStorage.setItem('dontShowStakingBannerTestnet3', 'true') + window.localStorage.setItem(localStorageVars.STAKING_BANNER, 'true') setState({ shouldShowStakingBanner: false, }) } const closePremiumBanner = (state) => { - window.localStorage.setItem('dontShowPremiumBanner', 'true') + window.localStorage.setItem(localStorageVars.PREMIUM_BANNER, 'true') setState({ shouldShowPremiumBanner: false, }) diff --git a/app/frontend/localStorage.ts b/app/frontend/localStorage.ts new file mode 100644 index 0000000000..665c7cb7b1 --- /dev/null +++ b/app/frontend/localStorage.ts @@ -0,0 +1,8 @@ +const localStorageVars = { + WELCOME: 'dontShowDisclaimer', + INFO_MODAL: 'dontShowInfoModal', + PREMIUM_BANNER: 'dontShowPremiumBanner', + STAKING_BANNER: 'dontShowStakingBannerTestnet3', +} + +export {localStorageVars} diff --git a/app/frontend/state.ts b/app/frontend/state.ts index 7528087dc1..15bc5e3db9 100644 --- a/app/frontend/state.ts +++ b/app/frontend/state.ts @@ -1,4 +1,5 @@ import {ADALITE_CONFIG} from './config' +import {localStorageVars} from './localStorage' interface Transaction {} @@ -147,15 +148,17 @@ const initialState: State = { hint: 'Hint: Ensure that your mnemonic is without mistake.', }, displayWelcome: - !(window.localStorage.getItem('dontShowDisclaimer') === 'true') && + !(window.localStorage.getItem(localStorageVars.WELCOME) === 'true') && ADALITE_CONFIG.ADALITE_DEVEL_AUTO_LOGIN !== 'true', currentTab: 'wallet-info', walletIsLoaded: false, shouldShowStakingBanner: !( - window.localStorage.getItem('dontShowStakingBannerTestnet3') === 'true' + window.localStorage.getItem(localStorageVars.STAKING_BANNER) === 'true' ), - shouldShowPremiumBanner: !(window.localStorage.getItem('dontShowPremiumBanner') === 'true'), - displayInfoModal: !(window.localStorage.getItem('dontShowInfoModal') === 'true'), + shouldShowPremiumBanner: !( + window.localStorage.getItem(localStorageVars.PREMIUM_BANNER) === 'true' + ), + displayInfoModal: !(window.localStorage.getItem(localStorageVars.INFO_MODAL) === 'true'), errorBannerContent: '', visibleAddresses: [], // todo - object (sub-state) from send-ada form