Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wallet): native share should point to opensea link #20222

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 22 additions & 11 deletions src/status_im/contexts/wallet/collectible/events.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns status-im.contexts.wallet.collectible.events
(:require [camel-snake-kebab.extras :as cske]
[react-native.platform :as platform]
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
[taoensso.timbre :as log]
[utils.ethereum.chain :as chain]
Expand Down Expand Up @@ -200,25 +201,35 @@

(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 (if platform/ios?
{:activityItemSources
[{:placeholderItem {:type :text
:content uri}
:item {:default {:type :url
:content uri}}
:linkMetadata {:title title}}]}
{:title title
:subject title
:url uri
:isNewTask true})}]]]}))

(rf/reg-event-fx :wallet/share-collectible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that in-sheet? as an argument adds unnecessary knowledge about the outer context to this event. Instead we can pass dispatch-timeout and make decision of selecting dispatch vs dispatch-later based on it. And :hide-bottom-sheet could be called outside, where knowledge about UI details exist. This will make :wallet/share-collectible more flexible.
Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's a good point! will adjust to that!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm on reviewing this, I think one thing to consider is that in-sheet? will hide the bottom sheet.
But anyway I see there is only one use of this function and it's in a bottom sheet, so I'll just remove that parameter altogether :)

(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
23 changes: 17 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,14 @@
: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}])}]]]))

"222"
"https://nft-cdn.alchemy.com/eth-mainnet/219530f9b3a7901f02169334d593823e"
"Tengria #913"
{:contract-id {:chain-id 1 :address "0x1a4ceef5d575c2228d142ef862a9b60be8161e7f"} :token-id "913"}

{:contract-id {:chain-id 1 :address "0x1a4ceef5d575c2228d142ef862a9b60be8161e7f"} :token-id "913"}
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 @@ -79,7 +79,8 @@
(js/setTimeout #(rf/dispatch [:wallet/clear-last-collectible-details]) 700))

(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 @@ -110,7 +111,8 @@
{:content (fn []
[options-drawer/view
{:name title
:image picture}])
:image picture
:id id}])
:theme theme}])}]
:center-opacity title-opacity}]]]]))

Expand Down Expand Up @@ -197,7 +199,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 @@ -246,7 +249,8 @@
{collection-name :name} collection-data]
[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
17 changes: 7 additions & 10 deletions src/status_im/contexts/wallet/home/tabs/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
[utils.re-frame :as rf]))

(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)}])}])))
[{:keys [preview-url :collectible-data id]}]
(rf/dispatch [:show-bottom-sheet
{:content (fn []
[options-drawer/view
{:id id
:name (:name collectible-data)
:image (:uri preview-url)}])}]))

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