From eb020423b6901a89721aaedc03c69df74293ca7a Mon Sep 17 00:00:00 2001 From: Erik Seppanen Date: Mon, 12 Jun 2023 15:04:00 -0400 Subject: [PATCH] Add featured-community data #16015 --- src/status_im/communities/core.cljs | 28 +++++++++++++++++++++ src/status_im/multiaccounts/login/core.cljs | 1 + src/status_im2/subs/communities.cljs | 2 +- src/status_im2/subs/root.cljs | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index 3096cf44e79..4c4aad28783 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -61,6 +61,13 @@ {} categ)) +(defn <-featured-communities-rpc + [r] + (set/rename-keys r + {:contractCommunities :contract-communities + :contractFeaturedCommunities :contract-featured-communities + :unknownCommunities :unknown-communities})) + (defn <-rpc [c] (-> c @@ -131,6 +138,18 @@ db communities)}) +(rf/defn handle-featured-communities + {:events [::fetched-featured]} + [{:keys [db]} communities] + (let [communities (<-featured-communities-rpc communities)] + {:db db} + ;; {:db (reduce (fn [db {:keys [id] :as community}] + ;; (assoc-in db [:featured-communities id] (<-rpc community))) + ;; db + ;; (map #(get (:communities communities) (keyword %)) + ;; (:contract-featured-communities communities)))} + )) + (rf/defn handle-my-pending-requests-to-join {:events [:communities/fetched-my-communities-requests-to-join]} [{:keys [db]} my-requests] @@ -307,6 +326,15 @@ (log/error "failed to fetch communities" %) (re-frame/dispatch [::failed-to-fetch %]))}]}) +(rf/defn fetch-featured + [_] + {:json-rpc/call [{:method "wakuext_curatedCommunities" + :params [] + :on-success #(re-frame/dispatch [::fetched-featured %]) + :on-error #(do + (log/error "failed to fetch featured communities" %) + (re-frame/dispatch [::failed-to-fetch %]))}]}) + (rf/defn chat-created {:events [::chat-created]} [_ community-id user-pk] diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index 0bd541d629e..01dd79c3b8f 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -439,6 +439,7 @@ (initialize-wallet-connect) (get-node-config) (communities/fetch) + (communities/fetch-featured) (communities/fetch-collapsed-community-categories) (communities/check-and-delete-pending-request-to-join) (logging/set-log-level (:log-level multiaccount)) diff --git a/src/status_im2/subs/communities.cljs b/src/status_im2/subs/communities.cljs index 54a0db8181b..eaeedb59e0c 100644 --- a/src/status_im2/subs/communities.cljs +++ b/src/status_im2/subs/communities.cljs @@ -72,7 +72,7 @@ (re-frame/reg-sub :communities/featured-communities - :<- [:communities] + :<- [:featured-communities] (fn [communities] (vals communities))) diff --git a/src/status_im2/subs/root.cljs b/src/status_im2/subs/root.cljs index 07bca624fbd..985eb594c1a 100644 --- a/src/status_im2/subs/root.cljs +++ b/src/status_im2/subs/root.cljs @@ -259,6 +259,8 @@ (reg-root-key-sub :communities/collapsed-categories :communities/collapsed-categories) (reg-root-key-sub :communities/selected-tab :communities/selected-tab) +(reg-root-key-sub :featured-communities :featured-communities) + (reg-root-key-sub :activity-center :activity-center) (reg-root-key-sub :bug-report/description-error :bug-report/description-error)