From 7065f4abd23ab1c4e49310407f3e9257bac0419b Mon Sep 17 00:00:00 2001 From: Mohsen Date: Sun, 10 Mar 2024 18:56:45 +0300 Subject: [PATCH] [#19101] feat: share contact profile (#19154) --- src/react_native/core.cljs | 4 ++++ src/status_im/common/universal_links.cljs | 2 +- .../contexts/profile/contact/actions/view.cljs | 10 ++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/react_native/core.cljs b/src/react_native/core.cljs index 8c055b4027..ef122682c3 100644 --- a/src/react_native/core.cljs +++ b/src/react_native/core.cljs @@ -224,3 +224,7 @@ (defn open-url [link] (.openURL ^js linking link)) (def set-status-bar-style react-native/StatusBar.setBarStyle) + +(defn sharing + [content] + (.share (.-Share ^js react-native) (clj->js content))) diff --git a/src/status_im/common/universal_links.cljs b/src/status_im/common/universal_links.cljs index c32ed56010..d50517cf5c 100644 --- a/src/status_im/common/universal_links.cljs +++ b/src/status_im/common/universal_links.cljs @@ -186,7 +186,7 @@ :params [public-key] :on-success (fn [url] (rf/dispatch [:universal-links/save-profile-url public-key url]) - (when (fn? on-success) (on-success))) + (when (fn? on-success) (on-success url))) :on-error #(log/error "failed to wakuext_shareUserURLWithData" {:error % :public-key public-key})}]}))) diff --git a/src/status_im/contexts/profile/contact/actions/view.cljs b/src/status_im/contexts/profile/contact/actions/view.cljs index 94df7acc31..7d7c3a0f5b 100644 --- a/src/status_im/contexts/profile/contact/actions/view.cljs +++ b/src/status_im/contexts/profile/contact/actions/view.cljs @@ -29,7 +29,13 @@ :on-success #(rf/dispatch [:open-modal :share-contact])}])) [public-key]) - has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) [nickname])] + has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) [nickname]) + on-share-profile (rn/use-callback + (fn [] + (rf/dispatch [:universal-links/generate-profile-url + {:public-key public-key + :on-success #(rn/sharing {:message %})}])) + [public-key])] [quo/action-drawer [[{:icon :i/edit :label (if has-nickname? @@ -43,7 +49,7 @@ :accessibility-label :show-qr-code} {:icon :i/share :label (i18n/label :t/share-profile) - :on-press not-implemented/alert + :on-press on-share-profile :accessibility-label :share-profile} (when has-nickname? {:icon :i/delete