From 4514afd166e019789187e845c07b34fa89ba1ec3 Mon Sep 17 00:00:00 2001 From: FabianLars Date: Tue, 5 Nov 2024 18:56:46 +0100 Subject: [PATCH] same for the rust side --- .changes/fix-deep-link-onopenurl-current.md | 1 + plugins/deep-link/src/lib.rs | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.changes/fix-deep-link-onopenurl-current.md b/.changes/fix-deep-link-onopenurl-current.md index c128c594..3ede6ebd 100644 --- a/.changes/fix-deep-link-onopenurl-current.md +++ b/.changes/fix-deep-link-onopenurl-current.md @@ -1,4 +1,5 @@ --- +deep-link: patch deep-link-js: patch --- diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 25cdd317..80153359 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -478,13 +478,10 @@ impl OpenUrlEvent { } impl DeepLink { - /// Handle a new deep link being triggered to open the app. + /// Helper function for the `deep-link://new-url` event to run a function each time the protocol is triggered while the app is running. /// - /// To avoid race conditions, if the app was started with a deep link, - /// the closure gets immediately called with the deep link URL. + /// Use `get_current` on app load to check whether your app was started via a deep link. pub fn on_open_url(&self, f: F) -> EventId { - let f = Arc::new(f); - let f_ = f.clone(); let event_id = self.app.listen("deep-link://new-url", move |event| { if let Ok(urls) = serde_json::from_str(event.payload()) { f(OpenUrlEvent { @@ -494,13 +491,6 @@ impl DeepLink { } }); - if let Ok(Some(current)) = self.get_current() { - f_(OpenUrlEvent { - id: event_id, - urls: current, - }) - } - event_id } }