Skip to content

Commit 78f7e57

Browse files
committed
fix: show activity list in savings/spending wallet when balance is zero but activities exist
When savings (or spending) balance was 0, tapping the wallet card showed the empty state "SEND BITCOIN TO YOUR SAVING BALANCE" screen instead of the activity list. This happened because the activity list visibility was gated solely on balance > 0. Now the activity list is shown when there's either a positive balance OR existing activities. The empty state is only shown when both balance is zero AND there are no activities. The transfer button remains gated behind a positive balance since there's nothing to transfer when balance is zero. Fixes #464
1 parent 352ee90 commit 78f7e57

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

Bitkit/Views/Wallets/SavingsWalletView.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ struct SavingsWalletView: View {
66
@EnvironmentObject var navigation: NavigationViewModel
77
@EnvironmentObject var wallet: WalletViewModel
88

9+
/// Whether there are any onchain activities to display
10+
private var hasOnchainActivities: Bool {
11+
guard let activities = activity.onchainActivities else { return false }
12+
return !activities.isEmpty
13+
}
14+
915
/// Calculate remaining duration for force close transfers
1016
private var forceCloseRemainingDuration: String? {
1117
guard let claimableAtHeight = wallet.forceCloseClaimableAtHeight,
@@ -42,8 +48,8 @@ struct SavingsWalletView: View {
4248
.padding(.top, 16)
4349
}
4450

45-
if wallet.totalOnchainSats > 0 {
46-
if !GeoService.shared.isGeoBlocked {
51+
if wallet.totalOnchainSats > 0 || hasOnchainActivities {
52+
if wallet.totalOnchainSats > 0, !GeoService.shared.isGeoBlocked {
4753
transferButton
4854
.transition(.move(edge: .leading).combined(with: .opacity))
4955
.padding(.top, 32)
@@ -96,7 +102,7 @@ struct SavingsWalletView: View {
96102
.navigationBarHidden(true)
97103
.animation(.spring(response: 0.3), value: wallet.totalOnchainSats)
98104
.overlay {
99-
if wallet.totalOnchainSats == 0 {
105+
if wallet.totalOnchainSats == 0 && !hasOnchainActivities {
100106
EmptyStateView(type: .savings)
101107
.padding(.horizontal)
102108
.transition(.move(edge: .trailing).combined(with: .opacity))

Bitkit/Views/Wallets/SpendingWalletView.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ struct SpendingWalletView: View {
66
@EnvironmentObject var navigation: NavigationViewModel
77
@EnvironmentObject var wallet: WalletViewModel
88

9+
/// Whether there are any lightning activities to display
10+
private var hasLightningActivities: Bool {
11+
guard let activities = activity.lightningActivities else { return false }
12+
return !activities.isEmpty
13+
}
14+
915
var body: some View {
1016
ZStack(alignment: .top) {
1117
VStack(spacing: 0) {
@@ -27,8 +33,8 @@ struct SpendingWalletView: View {
2733
.padding(.top, 16)
2834
}
2935

30-
if wallet.totalLightningSats > 0 {
31-
if let channels = wallet.channels, !channels.isEmpty {
36+
if wallet.totalLightningSats > 0 || hasLightningActivities {
37+
if wallet.totalLightningSats > 0, let channels = wallet.channels, !channels.isEmpty {
3238
transferButton
3339
.transition(.move(edge: .leading).combined(with: .opacity))
3440
.padding(.top, 32)
@@ -81,7 +87,7 @@ struct SpendingWalletView: View {
8187
.navigationBarHidden(true)
8288
.animation(.spring(response: 0.3), value: wallet.totalLightningSats)
8389
.overlay {
84-
if wallet.totalLightningSats == 0 {
90+
if wallet.totalLightningSats == 0 && !hasLightningActivities {
8591
EmptyStateView(type: .spending)
8692
.padding(.horizontal)
8793
.transition(.move(edge: .trailing).combined(with: .opacity))

0 commit comments

Comments
 (0)