Skip to content

Commit 1c096e2

Browse files
committed
pr feedback
1 parent 198aac5 commit 1c096e2

File tree

4 files changed

+29
-63
lines changed

4 files changed

+29
-63
lines changed

packages/mobile-app/app/(drawer)/account/index.tsx

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StatusBar } from "expo-status-bar";
2-
import { useState, useRef, useEffect } from "react";
2+
import { useState } from "react";
33
import {
44
Layout,
55
Text,
@@ -49,7 +49,6 @@ interface Balance {
4949

5050
export default function Balances() {
5151
const hideBalances = useHideBalances();
52-
const longPressTimerRef = useRef<NodeJS.Timeout | null>(null);
5352
const facade = useFacade();
5453
const { account, accountName, isLoading } = useAccount();
5554
const scrollYOffset = useSharedValue(0);
@@ -110,30 +109,13 @@ export default function Balances() {
110109
},
111110
);
112111

113-
const handlePressIn = () => {
114-
longPressTimerRef.current = setTimeout(() => {
115-
setAppSetting({
116-
key: SettingsKey.HideBalances,
117-
value: hideBalances ? "false" : "true",
118-
});
119-
}, 3000);
112+
const handleLongPress = () => {
113+
setAppSetting({
114+
key: SettingsKey.HideBalances,
115+
value: hideBalances ? "false" : "true",
116+
});
120117
};
121118

122-
const handlePressOut = () => {
123-
if (longPressTimerRef.current) {
124-
clearTimeout(longPressTimerRef.current);
125-
longPressTimerRef.current = null;
126-
}
127-
};
128-
129-
useEffect(() => {
130-
return () => {
131-
if (longPressTimerRef.current) {
132-
clearTimeout(longPressTimerRef.current);
133-
}
134-
};
135-
}, []);
136-
137119
if (isLoading || !account) {
138120
return (
139121
<SafeAreaView>
@@ -207,7 +189,7 @@ export default function Balances() {
207189
paddingTop: 40,
208190
}}
209191
>
210-
<Pressable onPressIn={handlePressIn} onPressOut={handlePressOut}>
192+
<Pressable onLongPress={handleLongPress} delayLongPress={2000}>
211193
<Layout style={styles.headerBalance}>
212194
<Text category="h1" style={styles.balanceAmount}>
213195
{hideBalances
@@ -300,7 +282,9 @@ export default function Balances() {
300282
account.balances.iron.confirmed,
301283
hideBalances,
302284
account.balances.iron.assetId,
303-
getIronAsset.data?.verification,
285+
getIronAsset.data?.verification.status === "verified"
286+
? getIronAsset.data.verification
287+
: undefined,
304288
)}
305289
verified={
306290
getIronAsset.data?.verification.status === "verified"

packages/mobile-app/app/(drawer)/account/send/index.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CurrencyUtils } from "@ironfish/sdk";
77
import { useQueries } from "@tanstack/react-query";
88
import { Asset } from "@/data/facades/chain/types";
99
import { AccountBalance } from "@/data/facades/wallet/types";
10+
import { useHideBalances } from "@/hooks/useHideBalances";
1011
import {
1112
Layout,
1213
Text,
@@ -42,6 +43,7 @@ type TransactionState = "sending" | "sent" | "idle";
4243
export default function Send() {
4344
const facade = useFacade();
4445
const router = useRouter();
46+
const hideBalances = useHideBalances();
4547

4648
const [selectedAssetId, setSelectedAssetId] =
4749
useState<string>(IRON_ASSET_ID_HEX);
@@ -96,12 +98,12 @@ export default function Send() {
9698
return map;
9799
}, [getCustomAssets]);
98100

99-
// Create asset options for the select component
101+
// Update asset options to respect hide balances
100102
const assetOptions = useMemo(() => {
101103
const options = [
102104
{
103105
id: IRON_ASSET_ID_HEX,
104-
title: `IRON (${CurrencyUtils.render(getAccountResult.data?.balances.iron.available ?? "0")})`,
106+
title: `IRON (${hideBalances ? "•••••" : CurrencyUtils.render(getAccountResult.data?.balances.iron.available ?? "0")})`,
105107
},
106108
];
107109

@@ -110,20 +112,24 @@ export default function Send() {
110112
if (asset) {
111113
options.push({
112114
id: b.assetId,
113-
title: `${asset.name} (${CurrencyUtils.render(
114-
b.available,
115-
false,
116-
b.assetId,
117-
asset.verification.status === "verified"
118-
? asset.verification
119-
: undefined,
120-
)})`,
115+
title: `${asset.name} (${
116+
hideBalances
117+
? "•••••"
118+
: CurrencyUtils.render(
119+
b.available,
120+
false,
121+
b.assetId,
122+
asset.verification.status === "verified"
123+
? asset.verification
124+
: undefined,
125+
)
126+
})`,
121127
});
122128
}
123129
});
124130

125131
return options;
126-
}, [getAccountResult.data, assetMap]);
132+
}, [getAccountResult.data, assetMap, hideBalances]);
127133

128134
// Find the selected asset index
129135
const selectedIndex = useMemo(() => {
@@ -304,7 +310,7 @@ export default function Send() {
304310
{transactionState === "sending" ? "Sending..." : "Sent!"}
305311
</Text>
306312
<Text category="s1" style={styles.amountText}>
307-
{amount}{" "}
313+
{hideBalances ? "•••••" : amount}{" "}
308314
{selectedAssetId === IRON_ASSET_ID_HEX
309315
? "$IRON"
310316
: (assetMap.get(selectedAssetId)?.name ?? "Unknown")}{" "}

packages/mobile-app/hooks/useHideBalances.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useEffect, useState } from "react";
77
*/
88
export function useHideBalances(): boolean {
99
const facade = useFacade();
10-
const [hideBalances, setHideBalances] = useState(false);
10+
const [hideBalances, setHideBalances] = useState(true);
1111
const appSettings = facade.getAppSettings.useQuery();
1212

1313
useEffect(() => {

packages/mobile-app/utils/balance.utils.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)