Skip to content

Commit

Permalink
Fix contract call for communities
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed Aug 28, 2023
1 parent 6870000 commit 3b86b3d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 45 deletions.
1 change: 1 addition & 0 deletions src/status_im/communities/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,35 @@
[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?]
(if open?
(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)]
(fn []
(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
Expand Down Expand Up @@ -64,17 +68,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?)]]
Expand Down
1 change: 1 addition & 0 deletions src/status_im2/contexts/communities/discover/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down
34 changes: 12 additions & 22 deletions src/status_im2/contexts/communities/discover/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}]]
Expand Down Expand Up @@ -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]])))
2 changes: 1 addition & 1 deletion src/status_im2/contexts/communities/overview/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "bug/fix-contract-communities-call",
"commit-sha1": "563f2c7a9d891da235cedcfd6c9b47142b163cd5",
"src-sha256": "0ca8jrdqdpm6pdxjh6cnl2jvmps2qjh83813dcw9piqjvp5pjnjv"
}

0 comments on commit 3b86b3d

Please sign in to comment.