Skip to content

Commit 9b87893

Browse files
committed
fix: set autocap for advanced spend
1 parent 1f4241b commit 9b87893

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Bitkit/Views/Transfer/SpendingAdvancedView.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,23 @@ struct SpendingAdvancedView: View {
117117
}
118118
}
119119
.onChange(of: transfer.transferValues.maxLspBalance, initial: true) { updateInputCap() }
120-
.onChange(of: amountViewModel.maxExceededCount) { showMaxExceededToast() }
120+
.onChange(of: amountViewModel.maxExceededCount) { onMaxExceeded() }
121121
}
122122

123123
private func updateInputCap() {
124124
let maxLspBalance = transfer.transferValues.maxLspBalance
125125
amountViewModel.maxAmountOverride = maxLspBalance > 0 ? maxLspBalance : nil
126126
}
127127

128+
private func onMaxExceeded() {
129+
// Snap the input to the max so the user lands on the highest allowed amount.
130+
let maxLspBalance = transfer.transferValues.maxLspBalance
131+
if maxLspBalance > 0 {
132+
amountViewModel.updateFromSats(maxLspBalance, currency: currency)
133+
}
134+
showMaxExceededToast()
135+
}
136+
128137
private func showMaxExceededToast() {
129138
app.toast(
130139
type: .warning,

0 commit comments

Comments
 (0)