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?})
(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}]

View File

@ -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?)]]

View File

@ -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 []

View File

@ -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]])))

View File

@ -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])

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"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"
}