From 7c1594107f8a9feb6f4332b83525fa103ef1cb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 8 Oct 2025 17:23:59 -0700 Subject: [PATCH] Perform LNURL computation on the background in EventActionBar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is to reduce the amount of computation it takes to create the EventActionBar view Signed-off-by: Daniel D’Aquino --- .../Actions/ActionBar/Views/EventActionBar.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/damus/Features/Actions/ActionBar/Views/EventActionBar.swift b/damus/Features/Actions/ActionBar/Views/EventActionBar.swift index 4b7c6eed..7973b67d 100644 --- a/damus/Features/Actions/ActionBar/Views/EventActionBar.swift +++ b/damus/Features/Actions/ActionBar/Views/EventActionBar.swift @@ -36,10 +36,17 @@ struct EventActionBar: View { self.swipe_context = swipe_context } - var lnurl: String? { - damus_state.profiles.lookup_with_timestamp(event.pubkey)?.map({ pr in + @State var lnurl: String? = nil + + // Fetching an LNURL is expensive enough that it can cause a hitch. Use a special backgroundable function to fetch the value. + // Fetch on `.onAppear` + nonisolated func fetchLNURL() { + let lnurl = damus_state.profiles.lookup_with_timestamp(event.pubkey)?.map({ pr in pr?.lnurl }).value + DispatchQueue.main.async { + self.lnurl = lnurl + } } var show_like: Bool { @@ -231,6 +238,9 @@ struct EventActionBar: View { self.content .onAppear { self.bar.update(damus: damus_state, evid: self.event.id) + Task.detached(priority: .background, operation: { + self.fetchLNURL() + }) } .sheet(isPresented: $show_share_action, onDismiss: { self.show_share_action = false }) { if #available(iOS 16.0, *) {