Skip to content

Commit

Permalink
fix(wallet): native share should point to opensea link
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Son89 committed Jun 11, 2024
1 parent 6a32006 commit a7ac971
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/status_im/contexts/wallet/account/tabs/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
(rf/dispatch [:wallet/get-collectible-details id]))

(defn- on-collectible-long-press
[{:keys [preview-url collectible-details]}]
[{:keys [preview-url collectible-details id]}]
(rf/dispatch [:show-bottom-sheet
{:content (fn []
[options-drawer/view
{:name (:name collectible-details)
:image (:uri preview-url)}])}]))
:image (:uri preview-url)
:id id}])}]))

(defn- on-end-reached
[]
Expand Down
25 changes: 14 additions & 11 deletions src/status_im/contexts/wallet/collectible/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -200,25 +200,28 @@

(rf/reg-event-fx :wallet/trigger-share-collectible
(fn [_ [{:keys [title uri]}]]
{:fx [[:effects.share/open
{:title title
:message title
:url uri}]]}))
{:fx [[:dispatch
[:open-share
{:options {:title title
:subject title
:message uri
:isNewTask true}}]]]}))

(rf/reg-event-fx :wallet/share-collectible
(fn [_ [{:keys [title uri in-sheet?]}]]
(if in-sheet?
(fn [{:keys [db]} [{:keys [title token-id contract-address chain-id]}]]
(let [uri (collectible-utils/get-opensea-collectible-url
{:chain-id chain-id
:token-id token-id
:contract-address contract-address
:test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
:is-goerli-enabled? (get-in db [:profile/profile :is-goerli-enabled?])})]
{:fx [[:dispatch
[:hide-bottom-sheet]]
[:dispatch-later
{:ms 600
:dispatch [:wallet/trigger-share-collectible
{:title title
:uri uri}]}]]}
{:fx [[:dispatch
[:wallet/trigger-share-collectible
{:title title
:uri uri}]]]})))
:uri uri}]}]]})))

(rf/reg-event-fx
:wallet/navigate-to-opensea
Expand Down
16 changes: 10 additions & 6 deletions src/status_im/contexts/wallet/collectible/options/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
[utils.url :as url]))

(defn view
[{:keys [image name chain-id address]}]
(let [uri (url/replace-port image (rf/sub [:mediaserver/port]))]
[{:keys [image name id]}]
(let [chain-id (get-in id [:contract-id :chain-id])
token-id (:token-id id)
contract-address (get-in id [:contract-id :address])
uri (url/replace-port image (rf/sub [:mediaserver/port]))]
[quo/action-drawer
[[{:icon :i/link
:accessibility-label :view-on-etherscan
:on-press (fn []
(rf/dispatch [:wallet/navigate-to-chain-explorer-from-bottom-sheet
(external-links/get-explorer-url-by-chain-id chain-id)
address]))
contract-address]))
:label (i18n/label :t/view-on-eth)
:right-icon :i/external}]
[{:icon :i/save
Expand All @@ -34,6 +37,7 @@
:accessibility-label :share-collectible
:label (i18n/label :t/share-collectible)
:on-press #(rf/dispatch [:wallet/share-collectible
{:in-sheet? true
:title name
:uri uri}])}]]]))
{:token-id token-id
:contract-address contract-address
:chain-id chain-id
:title name}])}]]]))
12 changes: 8 additions & 4 deletions src/status_im/contexts/wallet/collectible/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
(def navigate-back #(rf/dispatch [:navigate-back]))

(defn animated-header
[{:keys [scroll-amount title-opacity page-nav-type picture title description theme]}]
[{:keys [scroll-amount title-opacity page-nav-type picture title description theme
id]}]
(let [blur-amount (header-animations/use-blur-amount scroll-amount)
layer-opacity (header-animations/use-layer-opacity
scroll-amount
Expand Down Expand Up @@ -106,7 +107,8 @@
{:content (fn []
[options-drawer/view
{:name title
:image picture}])
:image picture
:id id}])
:theme theme}])}]
:center-opacity title-opacity}]]]]))

Expand Down Expand Up @@ -192,7 +194,8 @@
[options-drawer/view
{:name collectible-name
:image
preview-uri}])}])}])))
preview-uri
:id id}])}])}])))
:on-collectible-load (fn []
;; We need to delay the measurement because the
;; navigation has an animation
Expand Down Expand Up @@ -240,7 +243,8 @@

[rn/view {:style (style/background-color theme)}
[animated-header
{:scroll-amount scroll-amount
{:id (:id collectible)
:scroll-amount scroll-amount
:title-opacity title-opacity
:page-nav-type :title-description
:picture preview-uri
Expand Down
15 changes: 6 additions & 9 deletions src/status_im/contexts/wallet/home/tabs/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@

(defn- on-collectible-long-press
[{:keys [preview-url collectible-details id]}]
(let [chain-id (get-in id [:contract-id :chain-id])
address (get-in id [:contract-id :address])]
(rf/dispatch [:show-bottom-sheet
{:content (fn []
[options-drawer/view
{:chain-id chain-id
:address address
:name (:name collectible-details)
:image (:uri preview-url)}])}])))
(rf/dispatch [:show-bottom-sheet
{:content (fn []
[options-drawer/view
{:id id
:name (:name collectible-details)
:image (:uri preview-url)}])}]))

(defn- on-collectible-press
[{:keys [id]}]
Expand Down

0 comments on commit a7ac971

Please sign in to comment.