Fix initial conversion on screen load

This commit is contained in:
minibits-cash
2025-08-19 23:49:16 +02:00
parent 353e8585a1
commit 835d0ff748
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ android {
applicationId "com.minibits_wallet"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 58044
versionCode 58045
versionName "0.3.0"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "minibits_wallet",
"version": "0.3.0-beta.3",
"version": "0.3.0-beta.5",
"private": true,
"scripts": {
"android:clean": "cd android && ./gradlew clean",
+6 -2
View File
@@ -57,6 +57,7 @@ export const AmountInput = forwardRef<TextInput, AmountInputProps>(
const [isConvertedValueVisible, setIsConvertedValueVisible] = useState<boolean>(false)
const [hasTopAmountFocusedOnce, setHasTopAmountFocusedOnce] = useState(false)
const [hasBottomAmountFocusedOnce, setHasBottomAmountFocusedOnce] = useState(false)
const [hasBeenFirstTimeConverted, setHasBeenFirstTimeConverted] = useState<boolean>(false)
const amountInputColor = useThemeColor("amountInput")
const convertedAmountColor = useThemeColor("headerSubTitle")
@@ -153,13 +154,16 @@ export const AmountInput = forwardRef<TextInput, AmountInputProps>(
} else {
setBottomValue("0")
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
useEffect(() => {
log.trace(`[useEffect] setTopValue call`, value)
setTopValue(value)
// eslint-disable-next-line react-hooks/exhaustive-deps
if(!hasBeenFirstTimeConverted && value && toNumber(value) > 0) {
setBottomValue(recalcBottom(value))
setHasBeenFirstTimeConverted(true)
}
}, [value])
// input change handlers (bi-directional)