From ca7a519f8917f1582c5b0f8090c8c5b67f468757 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Wed, 23 Aug 2023 11:55:39 +0100 Subject: [PATCH] Fix contract call for communities --- src/status_im/communities/core.cljs | 1 + .../actions/request_to_join/view.cljs | 32 +++++++---------- .../contexts/communities/discover/events.cljs | 1 + .../contexts/communities/discover/view.cljs | 34 +++++++------------ .../contexts/communities/overview/view.cljs | 2 +- status-go-version.json | 6 ++-- 6 files changed, 31 insertions(+), 45 deletions(-) diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index 051b4b4f96..496c107b83 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -81,6 +81,7 @@ {:pinMessageAllMembersEnabled :pin-message-all-members-enabled?}) (update :members walk/stringify-keys) (update :chats <-chats-rpc) + (update :token-permissions seq) (update :categories <-categories-rpc) (assoc :token-images (reduce (fn [acc {sym :symbol image :image}] diff --git a/src/status_im2/contexts/communities/actions/request_to_join/view.cljs b/src/status_im2/contexts/communities/actions/request_to_join/view.cljs index 1974f6d07a..8579ce799a 100644 --- a/src/status_im2/contexts/communities/actions/request_to_join/view.cljs +++ b/src/status_im2/contexts/communities/actions/request_to_join/view.cljs @@ -3,11 +3,11 @@ [react-native.core :as rn] [react-native.gesture :as gesture] [reagent.core :as reagent] + [status-im2.common.password-authentication.view :as password-authentication] [status-im2.contexts.communities.actions.community-rules-list.view :as community-rules] [status-im2.contexts.communities.actions.request-to-join.style :as style] [utils.i18n :as i18n] - [utils.re-frame :as rf] - [utils.requests :as requests])) + [utils.re-frame :as rf])) (defn request-to-join-text [open?] @@ -15,6 +15,14 @@ (i18n/label :t/join-open-community) (i18n/label :t/request-to-join))) +(defn join-community-and-navigate-back + [id] + (rf/dispatch [:password-authentication/show + {:content (fn [] [password-authentication/view])} + {:label (i18n/label :t/join-open-community) + :on-press #(rf/dispatch [:communities/request-to-join-with-password id %])}]) + (rf/dispatch [:navigate-back])) + (defn request-to-join [] (let [agreed-to-rules? (reagent/atom false)] @@ -22,12 +30,8 @@ (let [{:keys [permissions name id - images - can-join? - can-request-access? - requested-to-join-at]} (rf/sub [:get-screen-params]) - pending? (rf/sub [:communities/my-pending-request-to-join id]) - open? (not= 3 (:access permissions))] + images]} (rf/sub [:get-screen-params]) + open? (not= 3 (:access permissions))] [rn/view {:flex 1} [gesture/scroll-view {:style {:flex 1}} [rn/view style/page-container @@ -65,17 +69,7 @@ (i18n/label :t/cancel)] [quo/button {:accessibility-label :join-community-button - :on-press (fn [] - (if can-join? - (do - (rf/dispatch [:communities/request-to-join id]) - (rf/dispatch [:navigate-back])) - (do (and can-request-access? - (not pending?) - (requests/can-request-access-again? - requested-to-join-at)) - (rf/dispatch [:communities/request-to-join id]) - (rf/dispatch [:navigate-back])))) + :on-press #(join-community-and-navigate-back id) :disabled? (not @agreed-to-rules?) :container-style {:flex 1}} (request-to-join-text open?)]] diff --git a/src/status_im2/contexts/communities/discover/events.cljs b/src/status_im2/contexts/communities/discover/events.cljs index 0dad94fc75..4ad0f63409 100644 --- a/src/status_im2/contexts/communities/discover/events.cljs +++ b/src/status_im2/contexts/communities/discover/events.cljs @@ -37,6 +37,7 @@ :other (select-keys (:communities cc) other)})})) (rf/defn fetch-contract-communities + {:events [:fetch-contract-communities]} [_] {:json-rpc/call [{:method "wakuext_curatedCommunities" :params [] diff --git a/src/status_im2/contexts/communities/discover/view.cljs b/src/status_im2/contexts/communities/discover/view.cljs index 34639ee5d9..d898ffe4cc 100644 --- a/src/status_im2/contexts/communities/discover/view.cljs +++ b/src/status_im2/contexts/communities/discover/view.cljs @@ -6,25 +6,15 @@ [react-native.core :as rn] [react-native.platform :as platform] [reagent.core :as reagent] - [status-im2.common.resources :as resources] [status-im2.contexts.communities.actions.community-options.view :as options] [status-im.ui.components.react :as react] [status-im2.common.scroll-page.view :as scroll-page] [status-im2.contexts.communities.discover.style :as style] [utils.re-frame :as rf])) -(def mock-community-item-data ;; TODO: remove once communities are loaded with this data. - {:data {:community-color "#0052FF" - :status :gated - :locked? true - :tokens [{:id 1 - :group [{:id 1 - :token-icon (resources/get-mock-image :status-logo)}]}]}}) - (defn community-list-item [community-item _ _ {:keys [width view-type]}] - (let [item (merge community-item - (get mock-community-item-data :data)) + (let [item community-item cover {:uri (get-in (:images item) [:banner :uri])}] (if (= view-type :card-view) [quo/community-card-view-item @@ -150,9 +140,7 @@ :margin-bottom 16} (if (= view-type :card-view) [quo/community-card-view-item - {:community (merge community - (get mock-community-item-data :data) - {:cover cover}) + {:community (assoc community :cover cover) :on-press #(rf/dispatch [:communities/navigate-to-community (:id community)])}] [quo/community-list-item @@ -161,8 +149,7 @@ (rf/dispatch [:dismiss-keyboard]) (rf/dispatch [:communities/navigate-to-community (:id community)])) :on-long-press #(js/alert "TODO: to be implemented")} - (merge community - (get mock-community-item-data :data))])])) + community])])) (if communities communities communities-ids)) [:<> [rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]] @@ -243,9 +230,12 @@ (defn discover [] - (let [featured-communities (rf/sub [:communities/featured-contract-communities])] - [rn/view - {:style (style/discover-screen-container (colors/theme-colors - colors/white - colors/neutral-95))} - [discover-screen-content featured-communities]])) + (rf/dispatch [:fetch-contract-communities]) + (fn [] + (let [featured-communities (rf/sub + [:communities/featured-contract-communities])] + [rn/view + {:style (style/discover-screen-container (colors/theme-colors + colors/white + colors/neutral-95))} + [discover-screen-content featured-communities]]))) diff --git a/src/status_im2/contexts/communities/overview/view.cljs b/src/status_im2/contexts/communities/overview/view.cljs index 68a35f1a39..9dc631aece 100644 --- a/src/status_im2/contexts/communities/overview/view.cljs +++ b/src/status_im2/contexts/communities/overview/view.cljs @@ -175,7 +175,7 @@ node-offline? (and can-join? (not joined) pending?)] [:<> (when-not (or joined pending? invite-only? unknown-access?) - (if token-permissions + (if (seq token-permissions) [token-gates community] [quo/button {:on-press #(rf/dispatch [:open-modal :community-requests-to-join community]) diff --git a/status-go-version.json b/status-go-version.json index 0bb192e440..e1f05480dd 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.163.9", - "commit-sha1": "f2f599fe867a0eba90aaa717a29bb6e99cb5749e", - "src-sha256": "0p282pv2lz5f2b0vhpcx0nj74dp5mf7hb41l12js2hxsp21sprmj" + "version": "v0.166.1", + "commit-sha1": "d64633e37b99cc7685a79c9475007881eda1e43b", + "src-sha256": "0pddzb2n1c50zw67j01npswjyrks87dvk6pyhvxd6hkawqgs8ajr" }