Skip to content

Commit aa3d74a

Browse files
committed
Fix account head and balances
1 parent 4d7cf7f commit aa3d74a

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

packages/mobile-app/app/(tabs)/index.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { StatusBar } from "expo-status-bar";
22
import {
33
ActivityIndicator,
4+
Button,
45
ScrollView,
56
StyleSheet,
67
Text,
@@ -33,6 +34,9 @@ export default function Balances() {
3334
refetchInterval: 1000,
3435
});
3536

37+
const pauseSyncing = facade.pauseSyncing.useMutation();
38+
const resumeSyncing = facade.resumeSyncing.useMutation();
39+
3640
useEffect(() => {
3741
if (getAccountResult.data) {
3842
setAccount(getAccountResult.data.name);
@@ -78,11 +82,32 @@ export default function Balances() {
7882
{getWalletStatusResult.data &&
7983
getWalletStatusResult.data.status === "SCANNING" && (
8084
// TODO: Only show this if the wallet is behind a certain number of blocks to avoid flickering
81-
<>
85+
<View style={{ backgroundColor: "#eee" }}>
8286
<Text>{`Blocks Scanned: ${getAccountResult.data?.head?.sequence ?? "--"} / ${getWalletStatusResult.data.latestKnownBlock}`}</Text>
8387
<Text>Your balances may currently be inaccurate.</Text>
8488
<Text>Learn More</Text>
85-
</>
89+
<Button
90+
onPress={async () => {
91+
await pauseSyncing.mutateAsync(undefined);
92+
}}
93+
title="Pause"
94+
/>
95+
</View>
96+
)}
97+
{getWalletStatusResult.data &&
98+
getWalletStatusResult.data.status !== "SCANNING" && (
99+
// TODO: Once scanning starts automatically, this should only show in the "PAUSED" state.
100+
<View style={{ backgroundColor: "#eee" }}>
101+
<Text>{`Scanning Paused: ${getAccountResult.data?.head?.sequence ?? "--"} / ${getWalletStatusResult.data.latestKnownBlock}`}</Text>
102+
<Text>Your balances may currently be inaccurate.</Text>
103+
<Text>Learn More</Text>
104+
<Button
105+
onPress={async () => {
106+
await resumeSyncing.mutateAsync(undefined);
107+
}}
108+
title="Resume"
109+
/>
110+
</View>
86111
)}
87112
<View style={{ display: "flex", flexDirection: "row" }}>
88113
<LinkButton href="/send/" title="Send" />

packages/mobile-app/data/wallet/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ export class WalletDb {
666666

667667
async getAccountsWithHeads(network: Network) {
668668
const result = await this.db.transaction().execute(async (db) => {
669-
const accountPromise = this.db
669+
const accountPromise = db
670670
.selectFrom("accounts")
671671
.leftJoin("activeAccount", "accounts.id", "activeAccount.accountId")
672672
.selectAll("accounts")

packages/mobile-app/data/wallet/wallet.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ export class Wallet {
9090

9191
const accounts = await this.state.db.getAccountsWithHeads(network);
9292

93-
for (const account of accounts) {
94-
await this.getBalances(account.id, network);
95-
}
96-
9793
return await Promise.all(
9894
accounts.map(async (a) => {
9995
const balances = await this.getBalances(a.id, network);

0 commit comments

Comments
 (0)