Skip to content

Commit

Permalink
Fix schema error after logout (#19933)
Browse files Browse the repository at this point in the history
Detailed explanation:

The schema failure is due to utils.image-server/get-initials-avatar-uri being
called with a nil profile customization color right after the user confirms
logout.

Right after logging out, the subscription :profile/profile-with-image is
recomputed. One of its signal inputs is :profile/profile. Right after logout,
the output of sub :profile/profile is always nil (this is correct, nobody is
logged in). This means that the sub :profile/profile-with-image will try to
calculate the multiaccount URI by passing a nil profile. This is wasteful
computation and is also the cause of the schema for
utils.image-server/get-initials-avatar-uri to fail, because it expects the
profile's customization-color to be present.
  • Loading branch information
ilmotta committed May 9, 2024
1 parent 3e5d758 commit ab19140
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/status_im/subs/profile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@
:<- [:initials-avatar-font-file]
:<- [:theme]
(fn [[profile ens-names port font-file theme] [_ avatar-opts]]
(replace-multiaccount-image-uri profile ens-names port font-file avatar-opts theme)))
;; Right after logout, this subscription is recomputed, but the sub
;; `:profile/profile` output will always be nil. We skip any further
;; processing because it's wasteful and because it will trigger a schema
;; error.
(when profile
(replace-multiaccount-image-uri profile ens-names port font-file avatar-opts theme))))

(re-frame/reg-sub
:profile/image
Expand Down

0 comments on commit ab19140

Please sign in to comment.