open url refactor

This commit is contained in:
Ajay Sivan 2024-07-15 16:53:39 +05:30
parent 942c130d23
commit bb71d5ebdb
No known key found for this signature in database
GPG Key ID: 5F9AC120AE59597A
3 changed files with 16 additions and 2 deletions

View File

@ -9,7 +9,8 @@
(defn- crypto-on-ramp-item
[{:keys [name description fees logo-url site-url recurrent-site-url]} _ _ {:keys [tab]}]
(let [open-url (rn/use-callback (fn []
(rn/open-url (if (= tab :recurrent) recurrent-site-url site-url)))
(rf/dispatch [:open-url
(if (= tab :recurrent) recurrent-site-url site-url)]))
[site-url recurrent-site-url tab])]
[quo/settings-item
{:title name

View File

@ -12,7 +12,16 @@
[status-im.navigation.state :as state]
[status-im.navigation.view :as views]
[taoensso.timbre :as log]
[utils.re-frame :as rf]))
[utils.re-frame :as rf]
[clojure.string :as string]
[react-native.core :as react]
[utils.url :as url]))
(rf/reg-fx
:open-url
(fn [url]
(when (not (string/blank? url))
(.openURL ^js react/linking (url/normalize-url url)))))
(defn get-status-nav-color
[view-id theme]

View File

@ -135,3 +135,7 @@
{:fx [[:effects.share/open config]]})
(rf/reg-event-fx :open-share open-share)
(rf/reg-event-fx :open-url
(fn [_ [url]]
{:fx [[:open-url url]]}))