Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b858e3dd0 |
@@ -14,7 +14,8 @@
|
||||
[status-im2.contexts.activity-center.events :as activity-center]
|
||||
[status-im2.common.toasts.events :as toasts]
|
||||
[status-im2.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]))
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.communities.mock :as mock]))
|
||||
|
||||
(def crop-size 1000)
|
||||
|
||||
@@ -100,10 +101,10 @@
|
||||
(rf/defn handle-communities
|
||||
{:events [::fetched]}
|
||||
[{:keys [db]} communities]
|
||||
{:db (reduce (fn [db {:keys [id] :as community}]
|
||||
(assoc-in db [:communities id] (<-rpc community)))
|
||||
db
|
||||
communities)})
|
||||
{:db (mock/add-mock-data (reduce (fn [db {:keys [id] :as community}]
|
||||
(assoc-in db [:communities id] (<-rpc community)))
|
||||
db
|
||||
communities))})
|
||||
|
||||
(rf/defn handle-response
|
||||
[_ response-js]
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
(ns status-im.communities.mock
|
||||
(:require [status-im2.constants :as constants]))
|
||||
|
||||
(def status-channel-to-mock "5c328f54-4d40-4984-ae96-b946247d8dba")
|
||||
|
||||
(def community-gates
|
||||
{:join [[{:token "KNC"
|
||||
:amount 200}
|
||||
{:token "MANA"
|
||||
:amount 10}
|
||||
{:token "RARE"
|
||||
:amount 50}]
|
||||
[{:token "KNC"
|
||||
:amount 200}
|
||||
{:token "MANA"
|
||||
:amount 50}]]})
|
||||
|
||||
(def channel-gates
|
||||
{:read [[{:token "KNC"
|
||||
:amount 100}
|
||||
{:token "RARE"
|
||||
:amount 50}]
|
||||
[{:token "KNC"
|
||||
:amount 200}
|
||||
{:token "MANA"
|
||||
:amount 50}]]
|
||||
:write [[{:token "KNC"
|
||||
:amount 400}]
|
||||
[{:token "KNC"
|
||||
:amount 100}
|
||||
{:token "RARE"
|
||||
:amount 50}]]})
|
||||
|
||||
(defn add-mock-data
|
||||
[db]
|
||||
(if (get-in db [:communities constants/status-community-id])
|
||||
(-> db
|
||||
(assoc-in [:communities constants/status-community-id :gates] community-gates)
|
||||
(assoc-in [:communities constants/status-community-id :status] :gated)
|
||||
(assoc-in [:communities constants/status-community-id :chats status-channel-to-mock :gates]
|
||||
channel-gates))
|
||||
db))
|
||||
@@ -412,7 +412,8 @@
|
||||
(communities/fetch)
|
||||
(logging/set-log-level (:log-level multiaccount))
|
||||
(activity-center/notifications-fetch-unread-contact-requests)
|
||||
(activity-center/notifications-fetch-unread-count))))
|
||||
(activity-center/notifications-fetch-unread-count)
|
||||
#_(communities/resolve-mock-community-info))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::open-last-chat
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
(utils/join-existing-users-string user-list)]])
|
||||
|
||||
(defn channel-token-gating-details
|
||||
[name token-gating emoji channel-color]
|
||||
[name gates emoji channel-color]
|
||||
[rn/view {:height 350 :margin-top 20}
|
||||
[quo/token-gating
|
||||
{:channel {:name name
|
||||
@@ -42,15 +42,15 @@
|
||||
(js/alert
|
||||
"Entered channel"
|
||||
"Wuhuu!! You successfully entered the channel :)"))
|
||||
:gates token-gating}}]])
|
||||
:gates gates}}]])
|
||||
|
||||
(defn open-channel-token-gating-details
|
||||
[name token-gating emoji channel-color]
|
||||
[name gates emoji channel-color]
|
||||
(rf/dispatch
|
||||
[:bottom-sheet/show-sheet
|
||||
{:content
|
||||
(fn []
|
||||
[channel-token-gating-details name token-gating emoji channel-color])
|
||||
[channel-token-gating-details name gates emoji channel-color])
|
||||
:content-height 210}]))
|
||||
|
||||
(defn layout-y
|
||||
@@ -160,13 +160,13 @@
|
||||
:gates tokens}}]])
|
||||
|
||||
(defn add-on-press-handler
|
||||
[community-id {:keys [name emoji id locked? token-gating] :or {locked? false} :as chat}]
|
||||
[community-id {:keys [name emoji id locked? gates] :or {locked? false} :as chat}]
|
||||
(merge
|
||||
chat
|
||||
(if (and locked? token-gating)
|
||||
(if (and locked? gates)
|
||||
{:on-press #(open-channel-token-gating-details
|
||||
name
|
||||
token-gating
|
||||
gates
|
||||
emoji
|
||||
(colors/custom-color :pink 50))}
|
||||
|
||||
@@ -210,14 +210,16 @@
|
||||
|
||||
(defn community-content
|
||||
[{:keys [name description locked joined images
|
||||
status tokens tags requested-to-join-at id]
|
||||
status tags requested-to-join-at id]
|
||||
:as community}
|
||||
{:keys [on-categories-heights-changed
|
||||
on-first-channel-height-changed]}]
|
||||
(let [pending? (pos? requested-to-join-at)
|
||||
thumbnail-image (get-in images [:thumbnail])
|
||||
chats-by-category (rf/sub [:communities/categorized-channels id])
|
||||
users (rf/sub [:communities/users id])]
|
||||
(let [pending? (pos? requested-to-join-at)
|
||||
thumbnail-image (get-in images [:thumbnail])
|
||||
chats-by-category (rf/sub [:communities/categorized-channels id])
|
||||
users (rf/sub [:communities/users id])
|
||||
join-gates (rf/sub [:community/join-gates id])
|
||||
permission-tag-tokens (rf/sub [:community/permission-tag-tokens id])]
|
||||
[rn/view
|
||||
[rn/view {:padding-horizontal 20}
|
||||
(when (and (not joined)
|
||||
@@ -230,7 +232,7 @@
|
||||
[quo/permission-tag-container
|
||||
{:locked locked
|
||||
:status status
|
||||
:tokens tokens
|
||||
:tokens permission-tag-tokens
|
||||
:on-press #(rf/dispatch
|
||||
[:bottom-sheet/show-sheet
|
||||
{:content-height 210
|
||||
@@ -239,7 +241,7 @@
|
||||
[community-token-gating-details
|
||||
name
|
||||
thumbnail-image
|
||||
tokens])}])}]])
|
||||
join-gates])}])}]])
|
||||
(when (or pending? joined)
|
||||
[rn/view
|
||||
{:position :absolute
|
||||
|
||||
@@ -216,6 +216,34 @@
|
||||
(sort-by :position)
|
||||
(into []))))
|
||||
|
||||
|
||||
(def token-images
|
||||
{"KNC" (js/require "../resources/images/tokens/mainnet/KNC.png")
|
||||
"MANA" (js/require "../resources/images/tokens/mainnet/MANA.png")
|
||||
"RARE" (js/require "../resources/images/tokens/mainnet/RARE.png")
|
||||
"ETH" (js/require "../resources/images/tokens/mainnet/ETH.png")
|
||||
"DAI" (js/require "../resources/images/tokens/mainnet/DAI.png")})
|
||||
|
||||
(defn token-image
|
||||
[token]
|
||||
(get token-images token))
|
||||
|
||||
(defn enrich-gate-for-ui
|
||||
[{:keys [token] :as gate}]
|
||||
(assoc gate :token-img-src (token-image token) :is-sufficient? false))
|
||||
|
||||
(defn enrich-gates-vector-for-ui
|
||||
[gates]
|
||||
(vec (map enrich-gate-for-ui gates)))
|
||||
|
||||
(defn enrich-gates-for-ui
|
||||
[gates]
|
||||
(vec (map (fn [v]
|
||||
(if (vector? v)
|
||||
(enrich-gates-vector-for-ui v)
|
||||
(enrich-gate-for-ui v)))
|
||||
gates)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/categorized-channels
|
||||
(fn [[_ community-id]]
|
||||
@@ -223,7 +251,7 @@
|
||||
(re-frame/subscribe [:chats/chats])])
|
||||
(fn [[{:keys [joined categories chats]} full-chats-data] [_ community-id]]
|
||||
(reduce
|
||||
(fn [acc [_ {:keys [name categoryID id emoji can-post?]}]]
|
||||
(fn [acc [_ {:keys [name categoryID id emoji can-post? gates]}]]
|
||||
(let [category (keyword
|
||||
(get-in categories
|
||||
[categoryID :name]
|
||||
@@ -235,6 +263,11 @@
|
||||
#(vec (conj %1 %2))
|
||||
{:name name
|
||||
:emoji emoji
|
||||
:gates (merge
|
||||
(when (contains? gates :read)
|
||||
{:read (enrich-gates-for-ui (:read gates))})
|
||||
(when (contains? gates :write)
|
||||
{:write (enrich-gates-for-ui (:write gates))}))
|
||||
:unread-messages? (pos? unviewed-messages-count)
|
||||
:mentions-count (or unviewed-mentions-count 0)
|
||||
:locked? (or (not joined) (not can-post?))
|
||||
@@ -250,3 +283,33 @@
|
||||
{:full-name "Marcus C"}
|
||||
{:full-name "MNO PQR"}
|
||||
{:full-name "STU VWX"}]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:community/join-gates
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])])
|
||||
(fn [[{:keys [gates]}] _]
|
||||
(when gates
|
||||
{:join (enrich-gates-for-ui (gates :join))})))
|
||||
|
||||
(defn icons-for-permission-tag
|
||||
[gates]
|
||||
(vec (map-indexed (fn [i {:keys [token]}]
|
||||
{:id i :token-icon (token-image token)})
|
||||
gates)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:community/permission-tag-tokens
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])])
|
||||
(fn [[{:keys [gates]}] _]
|
||||
(when gates
|
||||
(let [join-gates (gates :join)
|
||||
first-item (first join-gates)]
|
||||
(if (vector? first-item)
|
||||
(vec (map-indexed (fn [i v]
|
||||
{:id i
|
||||
:group (icons-for-permission-tag v)})
|
||||
join-gates))
|
||||
[{:id 0
|
||||
:group (icons-for-permission-tag join-gates)}])))))
|
||||
|
||||
Reference in New Issue
Block a user