From e803a853818dfa148be93528178fd23a39b10d69 Mon Sep 17 00:00:00 2001 From: Evan Kaloudis Date: Tue, 9 Jul 2024 13:03:53 -0400 Subject: [PATCH] ZEUS-1503: Settings: Display: add ability to hide millisat amounts --- components/Amount.tsx | 10 ++++++ locales/en.json | 1 + stores/SettingsStore.ts | 15 ++++++++- views/Settings/Display.tsx | 68 +++++++++++++++++++++++++++++++++++--- 4 files changed, 88 insertions(+), 6 deletions(-) diff --git a/components/Amount.tsx b/components/Amount.tsx index 2b1831e77..9b8242b3d 100644 --- a/components/Amount.tsx +++ b/components/Amount.tsx @@ -13,6 +13,8 @@ import { Row } from './layout/Row'; import { Body } from './text/Body'; import LoadingIndicator from './LoadingIndicator'; +import stores from '../stores/Stores'; + type Units = 'sats' | 'BTC' | 'fiat'; interface AmountDisplayProps { @@ -95,6 +97,14 @@ function AmountDisplay({ // TODO this could probably be made more readable by componentizing the repeat bits switch (unit) { case 'sats': + const hideMsats = + !stores.settingsStore?.settings?.display + ?.showMillisatoshiAmounts; + if (hideMsats) { + const [wholeSats] = amount.toString().split('.'); + amount = wholeSats; + plural = amount === '1' ? false : true; + } return ( + + + + + {localeString( + 'views.Settings.Display.showMillisatoshiAmounts' + )} + + + { + this.setState({ + showMillisatoshiAmounts: + !showMillisatoshiAmounts + }); + await updateSettings({ + display: { + defaultView, + theme, + displayNickname, + bigKeypadButtons, + showAllDecimalPlaces, + showMillisatoshiAmounts: + !showMillisatoshiAmounts } }); }}