[#9107] Collectibles (except CryptoKitties) are not loaded (endless spinner) after relogin
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
ca41fefbf7
commit
d2ff665d6e
|
@ -14,7 +14,10 @@
|
||||||
[status-im.ui.components.icons.vector-icons :as icons]
|
[status-im.ui.components.icons.vector-icons :as icons]
|
||||||
[status-im.ui.screens.wallet.account.styles :as styles]
|
[status-im.ui.screens.wallet.account.styles :as styles]
|
||||||
[status-im.ui.screens.wallet.transactions.views :as history]
|
[status-im.ui.screens.wallet.transactions.views :as history]
|
||||||
[status-im.ethereum.core :as ethereum]))
|
[status-im.ethereum.core :as ethereum]
|
||||||
|
[status-im.ui.components.list-item.views :as list-item]
|
||||||
|
[status-im.utils.money :as money]
|
||||||
|
[status-im.wallet.utils :as wallet.utils]))
|
||||||
|
|
||||||
(def state (reagent/atom {:tab :assets}))
|
(def state (reagent/atom {:tab :assets}))
|
||||||
|
|
||||||
|
@ -66,6 +69,19 @@
|
||||||
[react/view {:style styles/divider}]
|
[react/view {:style styles/divider}]
|
||||||
[button (i18n/label :t/receive) :main-icons/receive #(re-frame/dispatch [:show-popover {:view :share-account :address address}])]]]))
|
[button (i18n/label :t/receive) :main-icons/receive #(re-frame/dispatch [:show-popover {:view :share-account :address address}])]]]))
|
||||||
|
|
||||||
|
(defn render-collectible [address]
|
||||||
|
(fn [{:keys [name icon amount] :as collectible}]
|
||||||
|
(let [items-number (money/to-fixed amount)
|
||||||
|
details? (pos? items-number)]
|
||||||
|
[list-item/list-item
|
||||||
|
{:title (wallet.utils/display-symbol collectible)
|
||||||
|
:subtitle name
|
||||||
|
:icon [list/item-image icon]
|
||||||
|
:on-press (when details?
|
||||||
|
#(re-frame/dispatch
|
||||||
|
[:show-collectibles-list collectible address]))
|
||||||
|
:accessories [items-number :chevron]}])))
|
||||||
|
|
||||||
(views/defview transactions [address]
|
(views/defview transactions [address]
|
||||||
(views/letsubs [{:keys [transaction-history-sections]}
|
(views/letsubs [{:keys [transaction-history-sections]}
|
||||||
[:wallet.transactions.history/screen address]]
|
[:wallet.transactions.history/screen address]]
|
||||||
|
@ -97,7 +113,7 @@
|
||||||
:footer [react/view
|
:footer [react/view
|
||||||
{:style {:height tabs.styles/tabs-diff
|
{:style {:height tabs.styles/tabs-diff
|
||||||
:align-self :stretch}}]
|
:align-self :stretch}}]
|
||||||
:render-fn accounts/render-collectible}]
|
:render-fn (render-collectible address)}]
|
||||||
[react/view {:align-items :center :margin-top 32}
|
[react/view {:align-items :center :margin-top 32}
|
||||||
[react/text {:style {:color colors/gray}}
|
[react/text {:style {:color colors/gray}}
|
||||||
(i18n/label :t/no-collectibles)]])
|
(i18n/label :t/no-collectibles)]])
|
||||||
|
|
|
@ -12,10 +12,8 @@
|
||||||
[status-im.wallet.utils :as wallet.utils]
|
[status-im.wallet.utils :as wallet.utils]
|
||||||
[status-im.ui.components.tabbar.styles :as tabs.styles]
|
[status-im.ui.components.tabbar.styles :as tabs.styles]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.utils.money :as money]
|
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.ui.screens.wallet.accounts.sheets :as sheets]
|
[status-im.ui.screens.wallet.accounts.sheets :as sheets]
|
||||||
[status-im.ethereum.core :as ethereum]
|
|
||||||
[status-im.ui.screens.wallet.accounts.styles :as styles]))
|
[status-im.ui.screens.wallet.accounts.styles :as styles]))
|
||||||
|
|
||||||
(def state (reagent/atom {:tab :assets}))
|
(def state (reagent/atom {:tab :assets}))
|
||||||
|
@ -79,45 +77,16 @@
|
||||||
[list/item-image icon]
|
[list/item-image icon]
|
||||||
[chat-icon/custom-icon-view-list (:name token) color])}]))
|
[chat-icon/custom-icon-view-list (:name token) color])}]))
|
||||||
|
|
||||||
(defn render-collectible [{:keys [name icon amount] :as collectible}]
|
(views/defview assets []
|
||||||
(let [items-number (money/to-fixed amount)
|
|
||||||
details? (pos? items-number)]
|
|
||||||
[list-item/list-item
|
|
||||||
{:title (wallet.utils/display-symbol collectible)
|
|
||||||
:subtitle name
|
|
||||||
:icon [list/item-image icon]
|
|
||||||
:on-press (when details?
|
|
||||||
#(re-frame/dispatch
|
|
||||||
[:show-collectibles-list collectible]))
|
|
||||||
:accessories [items-number :chevron]}]))
|
|
||||||
|
|
||||||
(views/defview assets-and-collections []
|
|
||||||
(views/letsubs [{:keys [tokens nfts]} [:wallet/all-visible-assets-with-values]
|
(views/letsubs [{:keys [tokens nfts]} [:wallet/all-visible-assets-with-values]
|
||||||
currency [:wallet/currency]]
|
currency [:wallet/currency]]
|
||||||
(let [{:keys [tab]} @state]
|
|
||||||
[react/view {:flex 1}
|
|
||||||
[react/view {:flex-direction :row :margin-bottom 8 :margin-horizontal 4}
|
|
||||||
[tab-title state :assets (i18n/label :t/wallet-assets) (= tab :assets)]
|
|
||||||
[tab-title state :nft (i18n/label :t/wallet-collectibles) (= tab :nft)]]
|
|
||||||
(if (= tab :assets)
|
|
||||||
[list/flat-list {:data tokens
|
[list/flat-list {:data tokens
|
||||||
:default-separator? false
|
:default-separator? false
|
||||||
:key-fn :name
|
:key-fn :name
|
||||||
:footer [react/view
|
:footer [react/view
|
||||||
{:style {:height tabs.styles/tabs-diff
|
{:style {:height tabs.styles/tabs-diff
|
||||||
:align-self :stretch}}]
|
:align-self :stretch}}]
|
||||||
:render-fn (render-asset (:code currency))}]
|
:render-fn (render-asset (:code currency))}]))
|
||||||
(if (seq nfts)
|
|
||||||
[list/flat-list {:data nfts
|
|
||||||
:default-separator? false
|
|
||||||
:key-fn :name
|
|
||||||
:footer [react/view
|
|
||||||
{:style {:height tabs.styles/tabs-diff
|
|
||||||
:align-self :stretch}}]
|
|
||||||
:render-fn render-collectible}]
|
|
||||||
[react/view {:align-items :center :margin-top 32}
|
|
||||||
[react/text {:style {:color colors/gray}}
|
|
||||||
(i18n/label :t/no-collectibles)]]))])))
|
|
||||||
|
|
||||||
(views/defview total-value []
|
(views/defview total-value []
|
||||||
(views/letsubs [currency [:wallet/currency]
|
(views/letsubs [currency [:wallet/currency]
|
||||||
|
@ -149,7 +118,7 @@
|
||||||
[icons/icon :main-icons/more {:accessibility-label :accounts-more-options}]]]]))
|
[icons/icon :main-icons/more {:accessibility-label :accounts-more-options}]]]]))
|
||||||
|
|
||||||
(views/defview accounts []
|
(views/defview accounts []
|
||||||
(views/letsubs [{:keys [accounts address keycard-key-uid]} [:multiaccount]]
|
(views/letsubs [{:keys [accounts keycard-key-uid]} [:multiaccount]]
|
||||||
[react/scroll-view {:horizontal true}
|
[react/scroll-view {:horizontal true}
|
||||||
[react/view {:flex-direction :row :padding-top 11 :padding-bottom 12}
|
[react/view {:flex-direction :row :padding-top 11 :padding-bottom 12}
|
||||||
(for [account accounts]
|
(for [account accounts]
|
||||||
|
@ -167,4 +136,4 @@
|
||||||
[react/view {:margin-top 8 :padding-horizontal 16}
|
[react/view {:margin-top 8 :padding-horizontal 16}
|
||||||
[total-value]
|
[total-value]
|
||||||
[accounts]]
|
[accounts]]
|
||||||
[assets-and-collections]]])
|
[assets]]])
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
(defmethod load-collectible-fx :default [_ _ _] nil)
|
(defmethod load-collectible-fx :default [_ _ _] nil)
|
||||||
|
|
||||||
(defmulti load-collectibles-fx (fn [_ symbol _ _] symbol))
|
(defmulti load-collectibles-fx (fn [_ symbol _ _ _] symbol))
|
||||||
|
|
||||||
(defmethod load-collectibles-fx :default [all-tokens symbol items-number address chain-id]
|
(defmethod load-collectibles-fx :default [all-tokens symbol items-number address chain]
|
||||||
{:load-collectibles-fx [all-tokens symbol items-number address chain-id]})
|
{:load-collectibles-fx [all-tokens symbol items-number address chain]})
|
||||||
|
|
||||||
(defn load-token [i items-number contract address symbol]
|
(defn load-token [i items-number contract address symbol]
|
||||||
(when (< i items-number)
|
(when (< i items-number)
|
||||||
|
@ -31,20 +31,20 @@
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:load-collectibles-fx
|
:load-collectibles-fx
|
||||||
(fn [[all-tokens symbol items-number address chain-id]]
|
(fn [[all-tokens symbol items-number address chain]]
|
||||||
(let [chain (ethereum/chain-id->chain-keyword chain-id)
|
(let [contract (:address (tokens/symbol->token all-tokens chain symbol))]
|
||||||
contract (:address (tokens/symbol->token all-tokens chain symbol))]
|
|
||||||
(load-token 0 items-number contract address symbol))))
|
(load-token 0 items-number contract address symbol))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:show-collectibles-list
|
:show-collectibles-list
|
||||||
(fn [{:keys [db]} [_ {:keys [symbol amount] :as collectible}]]
|
(fn [{:keys [db]} [_ {:keys [symbol amount] :as collectible} address]]
|
||||||
(let [chain-id (get-in constants/default-networks [(:network db) :config :NetworkId])
|
(let [chain (ethereum/chain-id->chain-keyword
|
||||||
|
(get-in constants/default-networks [(:networks/current-network db) :config :NetworkId]))
|
||||||
all-tokens (:wallet/all-tokens db)
|
all-tokens (:wallet/all-tokens db)
|
||||||
items-number (money/to-number amount)
|
items-number (money/to-number amount)
|
||||||
loaded-items-number (count (get-in db [:collectibles symbol]))]
|
loaded-items-number (count (get-in db [:collectibles symbol]))]
|
||||||
(merge (when (not= items-number loaded-items-number)
|
(merge (when (not= items-number loaded-items-number)
|
||||||
(load-collectibles-fx all-tokens symbol items-number (ethereum/default-address db) chain-id))
|
(load-collectibles-fx all-tokens symbol items-number address chain))
|
||||||
{:dispatch [:navigate-to :collectibles-list collectible]}))))
|
{:dispatch [:navigate-to :collectibles-list collectible]}))))
|
||||||
|
|
||||||
;; Crypto Kitties
|
;; Crypto Kitties
|
||||||
|
@ -168,9 +168,6 @@
|
||||||
(fn [o]
|
(fn [o]
|
||||||
[:load-collectible-failure kudos {tokenId (http/parse-payload o)}])}}))
|
[:load-collectible-failure kudos {tokenId (http/parse-payload o)}])}}))
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:load-collectible
|
:load-collectible
|
||||||
(fn [cofx [_ symbol token-id]]
|
(fn [cofx [_ symbol token-id]]
|
||||||
|
|
Loading…
Reference in New Issue