Skip to content

Commit

Permalink
fix: Not visible status bar on light theme (#21105)
Browse files Browse the repository at this point in the history
The issue occurred because we updated the theme value after setting the root
(not before), which caused the root to be initialized with the old theme value.
  • Loading branch information
Parveshdhull authored Aug 22, 2024
1 parent 6bf1aec commit 449b280
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/legacy/status_im/multiaccounts/logout/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
[{:keys [db] :as cofx} {:keys [auth-method logout?]}]
(let [key-uid (get-in db [:profile/profile :key-uid])]
(rf/merge cofx
{:dispatch [:init-root :progress]
{:dispatch [:update-theme-and-init-root :progress]
:effects.shell/reset-state nil
:hide-popover nil
::logout nil
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/onboarding/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
(merge
{:db (assoc db :profile/profiles-overview multiaccounts)}
(when-not (seq multiaccounts)
{:dispatch [:init-root :screen/onboarding.intro]}))))
{:dispatch [:update-theme-and-init-root :screen/onboarding.intro]}))))

(rf/defn password-set
{:events [:onboarding/password-set]}
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/onboarding/welcome/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
:colors [colors/neutral-100-opa-0 colors/neutral-100-opa-80]}])
[quo/button
{:on-press (fn []
(rf/dispatch [:init-root :shell-stack])
(rf/dispatch [:update-theme-and-init-root :shell-stack])
(rf/dispatch [:profile/show-testnet-mode-banner-if-enabled])
(rf/dispatch [:universal-links/process-stored-event]))
:type :primary
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/preview/quo/common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
(rf/dispatch [:navigate-back])
(do
(rf/dispatch [:theme/switch {:theme :dark}])
(rf/dispatch [:init-root root])))}]))
(rf/dispatch [:update-theme-and-init-root root])))}]))
4 changes: 2 additions & 2 deletions src/status_im/contexts/profile/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
(assoc :profile/profiles-overview profiles)
(update :profile/login #(select-profile % key-uid)))
db-with-settings)
:fx [[:dispatch [:init-root :screen/profile.profiles]]
:fx [[:dispatch [:update-theme-and-init-root :screen/profile.profiles]]
(when (and key-uid userConfirmed)
[:effects.biometric/check-if-available
{:key-uid key-uid
:on-success (fn [auth-method]
(rf/dispatch [:profile.login/check-biometric-success key-uid
auth-method]))}])]})
{:db db-with-settings
:fx [[:dispatch [:init-root :screen/onboarding.intro]]]}))))
:fx [[:dispatch [:update-theme-and-init-root :screen/onboarding.intro]]]}))))

(rf/reg-event-fx
:profile/update-setting-from-backup
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/contexts/profile/login/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@

(cond
pairing-completed?
[[:dispatch [:init-root :screen/onboarding.syncing-results]]]
[[:dispatch [:update-theme-and-init-root :screen/onboarding.syncing-results]]]

(get db :onboarding/new-account?)
[[:dispatch [:onboarding/finalize-setup]]]

:else
[[:dispatch [:init-root :shell-stack]]
[[:dispatch [:update-theme-and-init-root :shell-stack]]
[:dispatch [:profile/show-testnet-mode-banner-if-enabled]]]))})))

;; login phase 2: we want to load and show chats faster, so we split login into 2 phases
Expand Down Expand Up @@ -185,7 +185,7 @@
{:db (-> db
(assoc-in [:profile/login :password] password)
(assoc-in [:profile/login :processing] true))
:fx [[:dispatch [:init-root :progress]]
:fx [[:dispatch [:update-theme-and-init-root :progress]]
[:effects.profile/login
[(get-in db [:profile/login :key-uid])
(security/safe-unmask-data password)]]]})))
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/navigation/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(re-frame/dispatch [:bottom-sheet-hidden])
(when @state/root-id
(reset! theme/device-theme (rn/get-color-scheme))
(re-frame/dispatch [:init-root @state/root-id])
(re-frame/dispatch [:update-theme-and-init-root @state/root-id])
(re-frame/dispatch [:chat/check-last-chat])
(re-frame/dispatch [:alert-banners/restore-alert-banners]))
(rn/hide-splash-screen)))
Expand Down
1 change: 0 additions & 1 deletion src/status_im/navigation/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
(let [[status-bar-theme] (get-status-nav-color root-id theme)
root (get (roots/roots status-bar-theme) root-id)]
(dismiss-all-modals)
(rf/dispatch [:theme/switch {:view-id root-id}])
(reset! state/root-id (or (get-in root [:root :stack :id]) root-id))
(navigation/set-root root)
(state/navigation-state-reset [{:id root-id
Expand Down
7 changes: 7 additions & 0 deletions src/status_im/navigation/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@
(assoc :dispatch [:chat/close (:current-chat-id db)])))

(rf/defn init-root
"WARNING: Use `:update-theme-and-init-root` instead. `:init-root` should not be used directly."
{:events [:init-root]}
[{:keys [db]} root-id]
{:set-root [root-id (:theme db)]})

(rf/defn update-theme-and-init-root
{:events [:update-theme-and-init-root]}
[_ root-id]
{:fx [[:dispatch [:theme/switch {:view-id root-id}]]
[:dispatch [:init-root root-id]]]})

(rf/defn change-tab
{:events [:navigate-change-tab]}
[{:keys [db]} stack-id]
Expand Down

0 comments on commit 449b280

Please sign in to comment.