nwc: attach lud16 to profile when attaching wallet
This commit is contained in:
@@ -359,6 +359,23 @@ struct ContentView: View {
|
||||
self.muting = pubkey
|
||||
self.confirm_mute = true
|
||||
}
|
||||
.onReceive(handle_notify(.attached_wallet)) { notif in
|
||||
// update the lightning address on our profile when we attach a
|
||||
// wallet with an associated
|
||||
let nwc = notif.object as! WalletConnectURL
|
||||
guard let ds = self.damus_state,
|
||||
let lud16 = nwc.lud16,
|
||||
let keypair = ds.keypair.to_full(),
|
||||
let profile = ds.profiles.lookup(id: ds.pubkey),
|
||||
lud16 != profile.lud16
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
||||
profile.lud16 = lud16
|
||||
let ev = make_metadata_event(keypair: keypair, metadata: profile)
|
||||
ds.postbox.send(ev)
|
||||
}
|
||||
.onReceive(handle_notify(.broadcast_event)) { obj in
|
||||
let ev = obj.object as! NostrEvent
|
||||
guard let ds = self.damus_state else {
|
||||
|
||||
@@ -53,6 +53,7 @@ class WalletModel: ObservableObject {
|
||||
|
||||
func connect(_ nwc: WalletConnectURL) {
|
||||
self.settings?.nostr_wallet_connect = nwc.to_url().absoluteString
|
||||
notify(.attached_wallet, nwc)
|
||||
self.connect_state = .existing(nwc)
|
||||
self.previous_state = .existing(nwc)
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ extension Notification.Name {
|
||||
static var onlyzaps_mode: Notification.Name {
|
||||
return Notification.Name("hide_reactions")
|
||||
}
|
||||
static var attached_wallet: Notification.Name {
|
||||
return Notification.Name("attached_wallet")
|
||||
}
|
||||
}
|
||||
|
||||
func handle_notify(_ name: Notification.Name) -> NotificationCenter.Publisher {
|
||||
|
||||
Reference in New Issue
Block a user