diff --git a/src/status_im/contexts/communities/events.cljs b/src/status_im/contexts/communities/events.cljs index 5c8c11ea91..40cbc19be7 100644 --- a/src/status_im/contexts/communities/events.cljs +++ b/src/status_im/contexts/communities/events.cljs @@ -241,6 +241,13 @@ (rf/reg-event-fx :chat.ui/community-failed-to-fetch community-failed-to-fetch) +(defn- failed-to-fetch-community + [community-id err] + (rf/dispatch [:chat.ui/community-failed-to-fetch community-id]) + (log/error {:message + "Failed to request community info from mailserver" + :error err})) + (defn fetch-community [{:keys [db]} [{:keys [community-id update-last-opened-at?]}]] (when (and community-id (not (get-in db [:communities/fetching-communities community-id]))) @@ -250,14 +257,16 @@ :TryDatabase true :WaitForResponse true}] :on-success (fn [community] - (when update-last-opened-at? - (rf/dispatch [:communities/update-last-opened-at community-id])) - (rf/dispatch [:chat.ui/community-fetched community-id community])) - :on-error (fn [err] - (rf/dispatch [:chat.ui/community-failed-to-fetch community-id]) - (log/error {:message - "Failed to request community info from mailserver" - :error err}))}]})) + (if community + (do (when update-last-opened-at? + (rf/dispatch [:communities/update-last-opened-at + community-id])) + (rf/dispatch [:chat.ui/community-fetched community-id + community])) + (failed-to-fetch-community + community-id + "community wasn't found at the store node"))) + :on-error (partial failed-to-fetch-community community-id)}]})) (schema/=> fetch-community [:=>