From ab191407eda4c80b80cd6afa1c875b94653b2016 Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Thu, 9 May 2024 08:52:27 -0300 Subject: [PATCH] Fix schema error after logout (#19933) 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. --- src/status_im/subs/profile.cljs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/status_im/subs/profile.cljs b/src/status_im/subs/profile.cljs index 316e1a8de6..24b5dcefb0 100644 --- a/src/status_im/subs/profile.cljs +++ b/src/status_im/subs/profile.cljs @@ -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