mirror of
git://jb55.com/damus
synced 2024-10-06 03:33:22 +00:00
Show error on invalid lightning tip address
Changelog-Changed: Show error on invalid lightning tip address Closes: #752
This commit is contained in:
parent
85f86ee31f
commit
42ea150d45
@ -65,6 +65,8 @@ struct EditMetadataView: View {
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
@State var confirm_ln_address: Bool = false
|
||||
|
||||
init (damus_state: DamusState) {
|
||||
self.damus_state = damus_state
|
||||
@ -103,6 +105,10 @@ struct EditMetadataView: View {
|
||||
damus_state.pool.send(.event(metadata_ev))
|
||||
}
|
||||
}
|
||||
|
||||
func is_ln_valid(ln: String) -> Bool {
|
||||
return ln.contains("@") || ln.lowercased().starts(with: "lnurl")
|
||||
}
|
||||
|
||||
var nip05_parts: NIP05? {
|
||||
return NIP05.parse(nip05)
|
||||
@ -201,8 +207,18 @@ struct EditMetadataView: View {
|
||||
})
|
||||
|
||||
Button(NSLocalizedString("Save", comment: "Button for saving profile.")) {
|
||||
save()
|
||||
dismiss()
|
||||
if !ln.isEmpty && !is_ln_valid(ln: ln) {
|
||||
confirm_ln_address = true
|
||||
} else {
|
||||
save()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
.alert(NSLocalizedString("Invalid Tip Address", comment: "Title of alerting as invalid tip address."), isPresented: $confirm_ln_address) {
|
||||
Button(NSLocalizedString("Ok", comment: "Button to dismiss the alert.")) {
|
||||
}
|
||||
} message: {
|
||||
Text("The address should either begin with LNURL or should look like an email address.", comment: "Giving the description of the alert message.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user