Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contract call for communities #17091

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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?)]]
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]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, how was this even called before without an event name? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't, but communities were retrieved every 10s I believe (seems to often to be honest), but I think it still best for UX to retrieve them on landing on the page, just in case

[_]
{: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": "v0.166.1",
"commit-sha1": "d64633e37b99cc7685a79c9475007881eda1e43b",
"src-sha256": "0pddzb2n1c50zw67j01npswjyrks87dvk6pyhvxd6hkawqgs8ajr"
}