From 705a627dd55026e5071d2c945ddf5e1213d453e5 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Mon, 29 Jul 2019 11:37:29 -0400 Subject: [PATCH] from @nestordominguez: add hide balance setting --- src/ui/component/header/index.js | 1 + src/ui/component/header/view.jsx | 23 +++++++++++++++-------- src/ui/constants/settings.js | 1 + src/ui/page/settings/index.js | 1 + src/ui/page/settings/view.jsx | 10 ++++++++++ src/ui/redux/reducers/settings.js | 1 + 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/ui/component/header/index.js b/src/ui/component/header/index.js index 391bb7226..ed1b76797 100644 --- a/src/ui/component/header/index.js +++ b/src/ui/component/header/index.js @@ -12,6 +12,7 @@ const select = state => ({ roundedBalance: formatCredits(selectBalance(state) || 0, 2), currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state), automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state), + hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state), }); const perform = dispatch => ({ diff --git a/src/ui/component/header/view.jsx b/src/ui/component/header/view.jsx index e2a8e96d4..4dbb85374 100644 --- a/src/ui/component/header/view.jsx +++ b/src/ui/component/header/view.jsx @@ -19,10 +19,11 @@ type Props = { currentTheme: string, automaticDarkModeEnabled: boolean, setClientSetting: (string, boolean | string) => void, + hideBalance: boolean, }; const Header = (props: Props) => { - const { roundedBalance, history, setClientSetting, currentTheme, automaticDarkModeEnabled } = props; + const { roundedBalance, history, setClientSetting, currentTheme, automaticDarkModeEnabled, hideBalance } = props; function handleThemeToggle() { if (automaticDarkModeEnabled) { @@ -36,6 +37,18 @@ const Header = (props: Props) => { } } + function getAccountTitle() { + if (roundedBalance > 0 && !hideBalance) { + return ( + + {roundedBalance} + + ); + } + + return __('Account'); + } + return (
@@ -73,13 +86,7 @@ const Header = (props: Props) => { - {roundedBalance > 0 ? ( - - {roundedBalance} - - ) : ( - __('Account') - )} + {getAccountTitle()} history.push(`/$/account`)}> diff --git a/src/ui/constants/settings.js b/src/ui/constants/settings.js index 60f600998..3c30ce3ca 100644 --- a/src/ui/constants/settings.js +++ b/src/ui/constants/settings.js @@ -17,3 +17,4 @@ export const RESULT_COUNT = 'resultCount'; export const OS_NOTIFICATIONS_ENABLED = 'osNotificationsEnabled'; export const AUTO_DOWNLOAD = 'autoDownload'; export const SUPPORT_OPTION = 'supportOption'; +export const HIDE_BALANCE = 'hideBalance'; diff --git a/src/ui/page/settings/index.js b/src/ui/page/settings/index.js index d712b8264..c30f89506 100644 --- a/src/ui/page/settings/index.js +++ b/src/ui/page/settings/index.js @@ -26,6 +26,7 @@ const select = state => ({ osNotificationsEnabled: selectosNotificationsEnabled(state), autoDownload: makeSelectClientSetting(settings.AUTO_DOWNLOAD)(state), supportOption: makeSelectClientSetting(settings.SUPPORT_OPTION)(state), + hideBalance: makeSelectClientSetting(settings.HIDE_BALANCE)(state), }); const perform = dispatch => ({ diff --git a/src/ui/page/settings/view.jsx b/src/ui/page/settings/view.jsx index 7a7cc4070..10afc9654 100644 --- a/src/ui/page/settings/view.jsx +++ b/src/ui/page/settings/view.jsx @@ -44,6 +44,7 @@ type Props = { walletEncrypted: boolean, osNotificationsEnabled: boolean, supportOption: boolean, + hideBalance: boolean, }; type State = { @@ -151,6 +152,7 @@ class SettingsPage extends React.PureComponent { setDaemonSetting, setClientSetting, supportOption, + hideBalance, } = this.props; const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0; @@ -360,6 +362,14 @@ class SettingsPage extends React.PureComponent { } /> + + setClientSetting(SETTINGS.HIDE_BALANCE, !hideBalance)} + checked={hideBalance} + label={__('Hide wallet balance in header')} + /> diff --git a/src/ui/redux/reducers/settings.js b/src/ui/redux/reducers/settings.js index fab35433a..c5370d92b 100644 --- a/src/ui/redux/reducers/settings.js +++ b/src/ui/redux/reducers/settings.js @@ -29,6 +29,7 @@ const defaultState = { [SETTINGS.RESULT_COUNT]: Number(getLocalStorageSetting(SETTINGS.RESULT_COUNT, 50)), [SETTINGS.AUTO_DOWNLOAD]: getLocalStorageSetting(SETTINGS.AUTO_DOWNLOAD, true), [SETTINGS.OS_NOTIFICATIONS_ENABLED]: Boolean(getLocalStorageSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED, true)), + [SETTINGS.HIDE_BALANCE]: Boolean(getLocalStorageSetting(SETTINGS.HIDE_BALANCE, false)), }, isNight: false, languages: { en: 'English', pl: 'Polish', id: 'Bahasa Indonesia' }, // temporarily hard code these so we can advance i18n testing