diff --git a/src/status_im/contexts/communities/events.cljs b/src/status_im/contexts/communities/events.cljs index 83fe2b414b..1d779edce1 100644 --- a/src/status_im/contexts/communities/events.cljs +++ b/src/status_im/contexts/communities/events.cljs @@ -22,17 +22,17 @@ [{:keys [db]} [community-js]] (when community-js (let [{:keys [clock - token-permissions-check joined id last-opened-at] + token-permissions-check id last-opened-at] :as community} (data-store.communities/<-rpc community-js) previous-last-opened-at (get-in db [:communities id :last-opened-at])] (when (> clock (get-in db [:communities id :clock])) {:db (assoc-in db [:communities id] (assoc community :last-opened-at (max last-opened-at previous-last-opened-at))) + ;; NOTE(cammellos): these two looks suspicious, we should not check for permissions at + ;; every event signalled :fx [[:dispatch [:communities/check-permissions-to-join-community-with-all-addresses id]] - (when (not joined) - [:dispatch [:chat.ui/spectate-community id]]) (when (nil? token-permissions-check) [:dispatch [:communities/check-permissions-to-join-community id]])]})))) @@ -348,7 +348,8 @@ (navigate-to-serialized-community community-id) (rf/merge cofx - {:fx [[:dispatch + {:fx [[:dispatch [:chat.ui/spectate-community community-id]] + [:dispatch [:communities/fetch-community {:community-id community-id :update-last-opened-at? true}]] diff --git a/src/status_im/contexts/communities/events_test.cljs b/src/status_im/contexts/communities/events_test.cljs index 4f41477aa3..3db78e6cc1 100644 --- a/src/status_im/contexts/communities/events_test.cljs +++ b/src/status_im/contexts/communities/events_test.cljs @@ -178,7 +178,6 @@ (is (match? [[:dispatch [:communities/check-permissions-to-join-community-with-all-addresses community-id]] - [:dispatch [:chat.ui/spectate-community community-id]] [:dispatch [:communities/check-permissions-to-join-community community-id]]] (filter some? (:fx effects)))))) @@ -196,8 +195,7 @@ effects (events/handle-community {} [community])] (is (match? [[:dispatch - [:communities/check-permissions-to-join-community-with-all-addresses community-id]] - [:dispatch [:chat.ui/spectate-community community-id]]] + [:communities/check-permissions-to-join-community-with-all-addresses community-id]]] (filter some? (:fx effects)))))) (testing "given a community with lower clock" (let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]