Skip to content

Commit

Permalink
[#21483] fix: update collectible amounts after sending
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Dec 25, 2024
1 parent 0f036ca commit ddde37e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/status_im/contexts/wallet/collectible/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
(let [current-collectible-idx (get-in db [:wallet :accounts account :current-collectible-idx] 0)
collectibles-filter nil
data-type (collectible-data-types :header)
fetch-criteria {:fetch-type (fetch-type :fetch-if-not-cached)
fetch-criteria {:fetch-type (fetch-type :fetch-if-cache-old)
:max-cache-age-seconds max-cache-age-seconds}
chain-ids (chain/chain-ids db)
request-params [request-id
Expand Down Expand Up @@ -175,12 +175,22 @@
(let [address (first accounts)
pending-chain-ids (get-in db [:wallet :ui :collectibles :updating address])
updated-chain-ids (disj pending-chain-ids chainId)
all-chain-updated? (and (some? pending-chain-ids) (empty? updated-chain-ids))]
all-chain-updated? (or (nil? pending-chain-ids)
(and (some? pending-chain-ids) (empty? updated-chain-ids)))]
{:db (cond-> db
(some? pending-chain-ids)
(assoc-in [:wallet :ui :collectibles :updating address] updated-chain-ids))
:fx [(when all-chain-updated?
[:dispatch [:wallet/request-collectibles-for-account address]])]})))
[:dispatch [:wallet/collectible-amount-update-for-owners address]])]})))

(rf/reg-event-fx :wallet/collectible-amount-update-for-owners
(fn [{:keys [db]} [from-address]]
(let [to-address (get-in db
[:wallet :ui :send :transaction-for-signing :sendDetails :toAddress])
exist-to-account (contains? (get-in db [:wallet :accounts]) to-address)]
{:fx [[:dispatch [:wallet/request-collectibles-for-account from-address]]
(when exist-to-account
[:dispatch [:wallet/request-collectibles-for-account to-address]])]})))

(defn- update-collectibles-in-account
[existing-collectibles updated-collectibles]
Expand Down

0 comments on commit ddde37e

Please sign in to comment.