File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ class ActivityListViewModel {
4646 self . bdkClient = bdkClient
4747 self . transactions = transactions
4848 self . walletSyncState = walletSyncState
49+
50+ // Preload cached data synchronously so UI has content before first render
51+ // transactions + listUnspent items are available from the persisted wallet db
52+ if self . transactions. isEmpty {
53+ if let cached = try ? bdkClient. transactions ( ) {
54+ self . transactions = cached
55+ }
56+ }
57+ if self . localOutputs. isEmpty {
58+ if let cachedUtxos = try ? bdkClient. listUnspent ( ) {
59+ self . localOutputs = cachedUtxos
60+ }
61+ }
4962 }
5063
5164 func getTransactions( ) {
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ struct WalletView: View {
110110 ) ,
111111 perform: { _ in
112112 Task {
113+ // Show cached state first
114+ viewModel. getBalance ( )
115+ viewModel. getTransactions ( )
116+
117+ // Then sync and refresh
113118 await viewModel. syncOrFullScan ( )
114119 viewModel. getBalance ( )
115120 viewModel. getTransactions ( )
@@ -119,13 +124,14 @@ struct WalletView: View {
119124 )
120125 . task {
121126 viewModel. getBalance ( )
127+ viewModel. getTransactions ( )
122128 if isFirstAppear || newTransactionSent {
123129 await viewModel. syncOrFullScan ( )
124130 isFirstAppear = false
125131 newTransactionSent = false
126132 viewModel. getBalance ( )
133+ viewModel. getTransactions ( )
127134 }
128- viewModel. getTransactions ( )
129135 await viewModel. getPrices ( )
130136 }
131137 . onAppear {
You can’t perform that action at this time.
0 commit comments