Fix contract call for communities

This commit is contained in:
Andrea Maria Piana 2023-08-23 11:55:39 +01:00
parent a4717ae5d0
commit ca7a519f89
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
6 changed files with 31 additions and 45 deletions

View File

@ -81,6 +81,7 @@
{:pinMessageAllMembersEnabled :pin-message-all-members-enabled?}) {:pinMessageAllMembersEnabled :pin-message-all-members-enabled?})
(update :members walk/stringify-keys) (update :members walk/stringify-keys)
(update :chats <-chats-rpc) (update :chats <-chats-rpc)
(update :token-permissions seq)
(update :categories <-categories-rpc) (update :categories <-categories-rpc)
(assoc :token-images (assoc :token-images
(reduce (fn [acc {sym :symbol image :image}] (reduce (fn [acc {sym :symbol image :image}]

View File

@ -3,11 +3,11 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.gesture :as gesture] [react-native.gesture :as gesture]
[reagent.core :as reagent] [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.community-rules-list.view :as community-rules]
[status-im2.contexts.communities.actions.request-to-join.style :as style] [status-im2.contexts.communities.actions.request-to-join.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf] [utils.re-frame :as rf]))
[utils.requests :as requests]))
(defn request-to-join-text (defn request-to-join-text
[open?] [open?]
@ -15,6 +15,14 @@
(i18n/label :t/join-open-community) (i18n/label :t/join-open-community)
(i18n/label :t/request-to-join))) (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 (defn request-to-join
[] []
(let [agreed-to-rules? (reagent/atom false)] (let [agreed-to-rules? (reagent/atom false)]
@ -22,12 +30,8 @@
(let [{:keys [permissions (let [{:keys [permissions
name name
id id
images images]} (rf/sub [:get-screen-params])
can-join? open? (not= 3 (:access permissions))]
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))]
[rn/view {:flex 1} [rn/view {:flex 1}
[gesture/scroll-view {:style {:flex 1}} [gesture/scroll-view {:style {:flex 1}}
[rn/view style/page-container [rn/view style/page-container
@ -65,17 +69,7 @@
(i18n/label :t/cancel)] (i18n/label :t/cancel)]
[quo/button [quo/button
{:accessibility-label :join-community-button {:accessibility-label :join-community-button
:on-press (fn [] :on-press #(join-community-and-navigate-back id)
(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]))))
:disabled? (not @agreed-to-rules?) :disabled? (not @agreed-to-rules?)
:container-style {:flex 1}} :container-style {:flex 1}}
(request-to-join-text open?)]] (request-to-join-text open?)]]

View File

@ -37,6 +37,7 @@
:other (select-keys (:communities cc) other)})})) :other (select-keys (:communities cc) other)})}))
(rf/defn fetch-contract-communities (rf/defn fetch-contract-communities
{:events [:fetch-contract-communities]}
[_] [_]
{:json-rpc/call [{:method "wakuext_curatedCommunities" {:json-rpc/call [{:method "wakuext_curatedCommunities"
:params [] :params []

View File

@ -6,25 +6,15 @@
[react-native.core :as rn] [react-native.core :as rn]
[react-native.platform :as platform] [react-native.platform :as platform]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im2.common.resources :as resources]
[status-im2.contexts.communities.actions.community-options.view :as options] [status-im2.contexts.communities.actions.community-options.view :as options]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im2.common.scroll-page.view :as scroll-page] [status-im2.common.scroll-page.view :as scroll-page]
[status-im2.contexts.communities.discover.style :as style] [status-im2.contexts.communities.discover.style :as style]
[utils.re-frame :as rf])) [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 (defn community-list-item
[community-item _ _ {:keys [width view-type]}] [community-item _ _ {:keys [width view-type]}]
(let [item (merge community-item (let [item community-item
(get mock-community-item-data :data))
cover {:uri (get-in (:images item) [:banner :uri])}] cover {:uri (get-in (:images item) [:banner :uri])}]
(if (= view-type :card-view) (if (= view-type :card-view)
[quo/community-card-view-item [quo/community-card-view-item
@ -150,9 +140,7 @@
:margin-bottom 16} :margin-bottom 16}
(if (= view-type :card-view) (if (= view-type :card-view)
[quo/community-card-view-item [quo/community-card-view-item
{:community (merge community {:community (assoc community :cover cover)
(get mock-community-item-data :data)
{:cover cover})
:on-press #(rf/dispatch [:communities/navigate-to-community (:id community)])}] :on-press #(rf/dispatch [:communities/navigate-to-community (:id community)])}]
[quo/community-list-item [quo/community-list-item
@ -161,8 +149,7 @@
(rf/dispatch [:dismiss-keyboard]) (rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:communities/navigate-to-community (:id community)])) (rf/dispatch [:communities/navigate-to-community (:id community)]))
:on-long-press #(js/alert "TODO: to be implemented")} :on-long-press #(js/alert "TODO: to be implemented")}
(merge community community])]))
(get mock-community-item-data :data))])]))
(if communities communities communities-ids)) (if communities communities communities-ids))
[:<> [:<>
[rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]] [rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]]
@ -243,9 +230,12 @@
(defn discover (defn discover
[] []
(let [featured-communities (rf/sub [:communities/featured-contract-communities])] (rf/dispatch [:fetch-contract-communities])
[rn/view (fn []
{:style (style/discover-screen-container (colors/theme-colors (let [featured-communities (rf/sub
colors/white [:communities/featured-contract-communities])]
colors/neutral-95))} [rn/view
[discover-screen-content featured-communities]])) {:style (style/discover-screen-container (colors/theme-colors
colors/white
colors/neutral-95))}
[discover-screen-content featured-communities]])))

View File

@ -175,7 +175,7 @@
node-offline? (and can-join? (not joined) pending?)] node-offline? (and can-join? (not joined) pending?)]
[:<> [:<>
(when-not (or joined pending? invite-only? unknown-access?) (when-not (or joined pending? invite-only? unknown-access?)
(if token-permissions (if (seq token-permissions)
[token-gates community] [token-gates community]
[quo/button [quo/button
{:on-press #(rf/dispatch [:open-modal :community-requests-to-join community]) {:on-press #(rf/dispatch [:open-modal :community-requests-to-join community])

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.163.9", "version": "v0.166.1",
"commit-sha1": "f2f599fe867a0eba90aaa717a29bb6e99cb5749e", "commit-sha1": "d64633e37b99cc7685a79c9475007881eda1e43b",
"src-sha256": "0p282pv2lz5f2b0vhpcx0nj74dp5mf7hb41l12js2hxsp21sprmj" "src-sha256": "0pddzb2n1c50zw67j01npswjyrks87dvk6pyhvxd6hkawqgs8ajr"
} }