same for the rust side

pull/2008/head
FabianLars 9 months ago
parent c07697458a
commit 4514afd166
No known key found for this signature in database

@ -1,4 +1,5 @@
--- ---
deep-link: patch
deep-link-js: patch deep-link-js: patch
--- ---

@ -478,13 +478,10 @@ impl OpenUrlEvent {
} }
impl<R: Runtime> DeepLink<R> { impl<R: Runtime> DeepLink<R> {
/// 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, /// Use `get_current` on app load to check whether your app was started via a deep link.
/// the closure gets immediately called with the deep link URL.
pub fn on_open_url<F: Fn(OpenUrlEvent) + Send + Sync + 'static>(&self, f: F) -> EventId { pub fn on_open_url<F: Fn(OpenUrlEvent) + Send + Sync + 'static>(&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| { let event_id = self.app.listen("deep-link://new-url", move |event| {
if let Ok(urls) = serde_json::from_str(event.payload()) { if let Ok(urls) = serde_json::from_str(event.payload()) {
f(OpenUrlEvent { f(OpenUrlEvent {
@ -494,13 +491,6 @@ impl<R: Runtime> DeepLink<R> {
} }
}); });
if let Ok(Some(current)) = self.get_current() {
f_(OpenUrlEvent {
id: event_id,
urls: current,
})
}
event_id event_id
} }
} }

Loading…
Cancel
Save