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 {
46
46
self . bdkClient = bdkClient
47
47
self . transactions = transactions
48
48
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
+ }
49
62
}
50
63
51
64
func getTransactions( ) {
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ struct WalletView: View {
110
110
) ,
111
111
perform: { _ in
112
112
Task {
113
+ // Show cached state first
114
+ viewModel. getBalance ( )
115
+ viewModel. getTransactions ( )
116
+
117
+ // Then sync and refresh
113
118
await viewModel. syncOrFullScan ( )
114
119
viewModel. getBalance ( )
115
120
viewModel. getTransactions ( )
@@ -119,13 +124,14 @@ struct WalletView: View {
119
124
)
120
125
. task {
121
126
viewModel. getBalance ( )
127
+ viewModel. getTransactions ( )
122
128
if isFirstAppear || newTransactionSent {
123
129
await viewModel. syncOrFullScan ( )
124
130
isFirstAppear = false
125
131
newTransactionSent = false
126
132
viewModel. getBalance ( )
133
+ viewModel. getTransactions ( )
127
134
}
128
- viewModel. getTransactions ( )
129
135
await viewModel. getPrices ( )
130
136
}
131
137
. onAppear {
You can’t perform that action at this time.
0 commit comments