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