Skip to content

Commit c15e6e6

Browse files
committed
ui: always show latest height
1 parent e82c6cc commit c15e6e6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

BDKSwiftExampleWallet/View/WalletView.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SwiftUI
1111
struct WalletView: View {
1212
@AppStorage("balanceDisplayFormat") private var balanceFormat: BalanceDisplayFormat =
1313
.bitcoinSats
14+
@AppStorage("KyotoLastBlockHeight") private var kyotoLastHeight: Int = 0
1415
@Bindable var viewModel: WalletViewModel
1516
@Binding var sendNavigationPath: NavigationPath
1617
@State private var isFirstAppear = true
@@ -127,6 +128,19 @@ struct WalletView: View {
127128
viewModel.getTransactions()
128129
await viewModel.getPrices()
129130
}
131+
.onAppear {
132+
// Seed height from AppStorage on first show to avoid displaying 0 when Kyoto is active
133+
if viewModel.isKyotoClient,
134+
viewModel.currentBlockHeight == 0,
135+
kyotoLastHeight > 0 {
136+
viewModel.currentBlockHeight = UInt32(kyotoLastHeight)
137+
}
138+
}
139+
.onChange(of: viewModel.currentBlockHeight) { _, newValue in
140+
if newValue > 0 {
141+
kyotoLastHeight = Int(newValue)
142+
}
143+
}
130144

131145
}
132146
.navigationDestination(isPresented: $showAllTransactions) {

0 commit comments

Comments
 (0)