From dc12a0ff97303ee21e3cd5fd58c6b56c3bf4387c Mon Sep 17 00:00:00 2001 From: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:45:11 +0530 Subject: [PATCH] fix_: delay in fetching the currencies list (#21239) This commit fixes the delay in showing the currency symbol in the wallet by moving the RPC call to login phase 1 along with wallet initialisation. This helps us to improve the wallet UX by skipping the waiting to start the messenger. Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> --- src/status_im/contexts/profile/login/events.cljs | 4 +++- .../settings/language_and_currency/events.cljs | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/status_im/contexts/profile/login/events.cljs b/src/status_im/contexts/profile/login/events.cljs index 1c2136a577..56bb542432 100644 --- a/src/status_im/contexts/profile/login/events.cljs +++ b/src/status_im/contexts/profile/login/events.cljs @@ -62,6 +62,9 @@ ;; loading chats and communities. This globally helps alleviate ;; stuttering immediately after login. [:dispatch-later [{:ms 500 :dispatch [:wallet/initialize]}]] + ;; Fetching the currencies along with wallet initialization as + ;; we rely on it for displaying currency symbol + [:dispatch-later [{:ms 500 :dispatch [:settings/get-currencies]}]] [:logs/set-level log-level] @@ -95,7 +98,6 @@ [:dispatch-later [{:ms 1500 :dispatch [:profile.login/non-critical-initialization]}]] [:dispatch [:network/check-expensive-connection]] [:profile.settings/get-profile-picture key-uid] - [:settings/get-currencies] (when (ff/enabled? ::ff/wallet.wallet-connect) [:dispatch [:wallet-connect/init]]) (when (ff/enabled? ::ff/wallet.swap) diff --git a/src/status_im/contexts/settings/language_and_currency/events.cljs b/src/status_im/contexts/settings/language_and_currency/events.cljs index 4297041a75..50da7bf5da 100644 --- a/src/status_im/contexts/settings/language_and_currency/events.cljs +++ b/src/status_im/contexts/settings/language_and_currency/events.cljs @@ -1,6 +1,5 @@ (ns status-im.contexts.settings.language-and-currency.events - (:require [status-im.common.json-rpc.events :as json-rpc] - [status-im.contexts.settings.language-and-currency.data-store :as data-store] + (:require [status-im.contexts.settings.language-and-currency.data-store :as data-store] [utils.collection] [utils.re-frame :as rf])) @@ -11,8 +10,9 @@ :currencies (utils.collection/index-by :id all-currencies))}))) -(rf/reg-fx :settings/get-currencies +(rf/reg-event-fx :settings/get-currencies (fn [] - (json-rpc/call {:method "appgeneral_getCurrencies" - :on-success [:settings/get-currencies-success] - :on-error [:log-rpc-error {:event :settings/get-currencies}]}))) + {:fx [[:json-rpc/call + [{:method "appgeneral_getCurrencies" + :on-success [:settings/get-currencies-success] + :on-error [:log-rpc-error {:event :settings/get-currencies}]}]]]}))