Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions DashWallet/Sources/UI/Home/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,27 @@ struct HomeViewContent<Content: View>: View {
})

if viewModel.txItems.isEmpty {
Text(NSLocalizedString("There are no transactions to display", comment: ""))
.font(.caption)
.foregroundColor(Color.primary.opacity(0.5))
// An empty feed means "nothing yet" only once the first
// load has finished; before that it just means the
// reload is still running, so show progress rather than
// telling the user they have no transactions.
if viewModel.hasLoadedInitialTxItems {
Text(NSLocalizedString("There are no transactions to display", comment: ""))
.font(.caption)
.foregroundColor(Color.primary.opacity(0.5))
.padding(.top, 20)
} else {
HStack(spacing: 10) {
SwiftUI.ProgressView()
.progressViewStyle(CircularProgressViewStyle())

Text(NSLocalizedString("Loading transactions", comment: "Home"))
.font(.caption)
.foregroundColor(Color.primary.opacity(0.5))
}
.frame(maxWidth: .infinity)
.padding(.top, 20)
}
} else {
ForEach(viewModel.txItems) { group in
Section(header: SectionHeader(key: group.id, date: group.date)
Expand Down
17 changes: 16 additions & 1 deletion DashWallet/Sources/UI/Home/Views/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ class HomeViewModel: ObservableObject {
}

@Published private(set) var txItems: [TransactionGroup] = []

/// Whether the first full transaction load has finished, published on the
/// main thread for the home feed.
///
/// Distinct from the worker-queue `hasCompletedInitialLoad`, which guards
/// reload/incremental-update sequencing off the main thread. This one
/// exists so the view can tell "still loading" from "genuinely empty" —
/// `txItems` is empty in both cases, and rendering the empty-state copy
/// during the initial load tells the user they have no transactions
/// before that is known.
@Published private(set) var hasLoadedInitialTxItems: Bool = false
@Published var shortcutItems: [ShortcutAction] = []
@Published var showTimeSkewAlertDialog: Bool = false
@Published var showCoinJoinSweepDialog: Bool = false
Expand Down Expand Up @@ -243,9 +254,12 @@ class HomeViewModel: ObservableObject {
self.hasCompletedInitialLoad = false
self.isReloading = false

// Update UI-bound property on main thread
// Update UI-bound properties on main thread. The new network's
// history is loading from scratch, so the feed goes back to its
// loading state rather than claiming the wallet is empty.
DispatchQueue.main.async {
self.txItems = []
self.hasLoadedInitialTxItems = false
}

// Reload fresh data from the new network's wallet
Expand Down Expand Up @@ -501,6 +515,7 @@ class HomeViewModel: ObservableObject {

DispatchQueue.main.async {
self.txItems = array
self.hasLoadedInitialTxItems = true
if self.hasRewardsHistory != hasRewards {
self.hasRewardsHistory = hasRewards
}
Expand Down
3 changes: 3 additions & 0 deletions DashWallet/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,9 @@
/* No comment provided by engineer. */
"Local requested amount: %@" = "Local requested amount: %@";

/* Home */
"Loading transactions" = "Loading transactions";

/* Explore Dash/Merchants/Filters */
"Location" = "Location";

Expand Down
Loading