Skip to content

Commit

Permalink
Add featured-community data #16015
Browse files Browse the repository at this point in the history
  • Loading branch information
erikseppanen committed Jun 12, 2023
1 parent f38c855 commit eb02042
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/status_im/communities/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/status_im/multiaccounts/login/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/status_im2/subs/communities.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

(re-frame/reg-sub
:communities/featured-communities
:<- [:communities]
:<- [:featured-communities]
(fn [communities]
(vals communities)))

Expand Down
2 changes: 2 additions & 0 deletions src/status_im2/subs/root.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb02042

Please sign in to comment.