From bb32d72903dead180dbafab22248435202fd649e Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 10 May 2023 13:23:56 -0700 Subject: [PATCH] nwc: clear the zapper cache for our pubkey when we attach a new wallet --- damus/ContentView.swift | 6 ++++++ damus/Nostr/Profiles.swift | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/damus/ContentView.swift b/damus/ContentView.swift index d336143b..03df09ec 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -372,6 +372,12 @@ struct ContentView: View { return } + // clear zapper cache for old lud16 + if profile.lud16 != nil { + // TODO: should this be somewhere else, where we process profile events!? + invalidate_zapper_cache(pubkey: keypair.pubkey, profiles: ds.profiles, lnurl: ds.lnurls) + } + profile.lud16 = lud16 let ev = make_metadata_event(keypair: keypair, metadata: profile) ds.postbox.send(ev) diff --git a/damus/Nostr/Profiles.swift b/damus/Nostr/Profiles.swift index fa3f06d3..cf30d1fa 100644 --- a/damus/Nostr/Profiles.swift +++ b/damus/Nostr/Profiles.swift @@ -52,3 +52,9 @@ class Profiles { } } } + + +func invalidate_zapper_cache(pubkey: String, profiles: Profiles, lnurl: LNUrls) { + profiles.zappers.removeValue(forKey: pubkey) + lnurl.endpoints.removeValue(forKey: pubkey) +}