mirror of
https://github.com/status-im/status-react.git
synced 2025-01-23 17:29:08 +00:00
parent
1ee44259c4
commit
34c95c42d1
@ -38,10 +38,12 @@
|
||||
:always
|
||||
(update :contacts conj (:id member))))
|
||||
|
||||
(defn community-chat-id->channel-id [chat-id] (subs chat-id constants/community-id-length))
|
||||
|
||||
(defn decode-chat-id
|
||||
[chat-id]
|
||||
(let [community-id (subs chat-id 0 constants/community-id-length)
|
||||
channel-id (subs chat-id constants/community-id-length)]
|
||||
channel-id (community-chat-id->channel-id chat-id)]
|
||||
{:community-id community-id
|
||||
:channel-id channel-id}))
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
||||
:as chat} (rf/sub [:chats/chat-by-id chat-id])
|
||||
pins-count (rf/sub [:chats/pin-messages-count chat-id])
|
||||
items (rf/sub [:communities/sorted-community-members-section-list
|
||||
community-id])
|
||||
community-id chat-id])
|
||||
theme (quo.theme/use-theme)]
|
||||
(rn/use-mount (fn []
|
||||
(rf/dispatch [:pin-message/load-pin-messages chat-id])))
|
||||
|
@ -1,6 +1,7 @@
|
||||
(ns status-im.subs.communities
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.data-store.chats :as data-store.chats]
|
||||
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.constants :as constants]
|
||||
@ -49,6 +50,16 @@
|
||||
(fn [[{:keys [members]}] _]
|
||||
members))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/community-chat-members
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])])
|
||||
(fn [[{:keys [members chats]}] [_ _ chat-id]]
|
||||
(let [channel-id (data-store.chats/community-chat-id->channel-id chat-id)]
|
||||
(if (get-in chats [channel-id :token-gated?])
|
||||
(get-in chats [channel-id :members])
|
||||
members))))
|
||||
|
||||
(defn- keys->names
|
||||
[public-keys profile]
|
||||
(reduce (fn [acc contact-identity]
|
||||
@ -80,10 +91,10 @@
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/sorted-community-members-section-list
|
||||
(fn [[_ community-id]]
|
||||
(fn [[_ community-id chat-id]]
|
||||
(let [profile (re-frame/subscribe [:profile/profile])
|
||||
members (re-frame/subscribe [:communities/community-members
|
||||
community-id])
|
||||
members (re-frame/subscribe [:communities/community-chat-members
|
||||
community-id chat-id])
|
||||
visibility-status-updates (re-frame/subscribe
|
||||
[:visibility-status-updates])
|
||||
my-status-update (re-frame/subscribe
|
||||
|
@ -10,7 +10,7 @@
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def community-id "0x1")
|
||||
(def community-id "0x02b5bdaf5a25fcfe2ee14c501fab1836b8de57f61621080c3d52073d16de0d98d6")
|
||||
|
||||
(h/deftest-sub :communities
|
||||
[sub-name]
|
||||
@ -461,32 +461,39 @@
|
||||
[sub-name]
|
||||
(testing "returns sorted community members per online status"
|
||||
(let [token-image-eth "data:image/jpeg;base64,/9j/2w"
|
||||
channel-id-1 "89f98a1e-6776-4e5f-8626-8ab9f855253f"
|
||||
channel-id-2 "a076358e-4638-470e-a3fb-584d0a542ce6"
|
||||
chat-id-1 (str community-id channel-id-1)
|
||||
chat-id-2 (str community-id channel-id-2)
|
||||
community {:id community-id
|
||||
:permissions {:access 3}
|
||||
:token-images {"ETH" token-image-eth}
|
||||
:name "Community super name"
|
||||
:chats {"89f98a1e-6776-4e5f-8626-8ab9f855253f"
|
||||
:chats {channel-id-1
|
||||
{:description "x"
|
||||
:emoji "🎲"
|
||||
:permissions {:access 1}
|
||||
:color "#88B0FF"
|
||||
:name "random"
|
||||
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
|
||||
:id "89f98a1e-6776-4e5f-8626-8ab9f855253f"
|
||||
:id channel-id-1
|
||||
:position 4
|
||||
:can-post? false
|
||||
:members {"0x04" {"roles" [1]}}}
|
||||
"a076358e-4638-470e-a3fb-584d0a542ce6"
|
||||
{:description "General channel for the community"
|
||||
:emoji "🥔"
|
||||
:permissions {:access 1}
|
||||
:color "#4360DF"
|
||||
:name "general"
|
||||
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
|
||||
:id "a076358e-4638-470e-a3fb-584d0a542ce6"
|
||||
:position 0
|
||||
:can-post? false
|
||||
:members {"0x04" {"roles" [1]}}}}
|
||||
:members nil}
|
||||
channel-id-2
|
||||
{:description "General channel for the community"
|
||||
:emoji "🥔"
|
||||
:permissions {:access 1}
|
||||
:color "#4360DF"
|
||||
:name "general"
|
||||
:categoryID "0c3c64e7-d56e-439b-a3fb-a946d83cb056"
|
||||
:id channel-id-2
|
||||
:position 0
|
||||
:token-gated? true
|
||||
:can-post? false
|
||||
:members {"0x01" {"roles" [1]}
|
||||
"0x02" {"roles" [1]}
|
||||
"0x05" {"roles" [1]}}}}
|
||||
:members {"0x01" {"roles" [1]}
|
||||
"0x02" {"roles" [1]}
|
||||
"0x03" {"roles" [1]}
|
||||
@ -500,8 +507,15 @@
|
||||
:visibility-status-updates
|
||||
{"0x01" {:status-type constants/visibility-status-always-online}
|
||||
"0x02" {:status-type constants/visibility-status-always-online}})
|
||||
(is (= [{:title (i18n/label :t/online)
|
||||
:data ["0x01" "0x02"]}
|
||||
{:title (i18n/label :t/offline)
|
||||
:data ["0x03" "0x04"]}]
|
||||
(rf/sub [sub-name community-id]))))))
|
||||
(testing "a non-token gated community should look at all members of a community"
|
||||
(is (= [{:title (i18n/label :t/online)
|
||||
:data ["0x01" "0x02"]}
|
||||
{:title (i18n/label :t/offline)
|
||||
:data ["0x03" "0x04"]}]
|
||||
(rf/sub [sub-name community-id chat-id-1]))))
|
||||
(testing "a token gated community should use the members option in the channel"
|
||||
(is (= [{:title (i18n/label :t/online)
|
||||
:data ["0x01" "0x02"]}
|
||||
{:title (i18n/label :t/offline)
|
||||
:data ["0x05"]}]
|
||||
(rf/sub [sub-name community-id chat-id-2])))))))
|
||||
|
@ -3,7 +3,7 @@
|
||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.180.31",
|
||||
"commit-sha1": "e0673ad1ffec65e3bd96a46b5054fc2d36071cc4",
|
||||
"src-sha256": "15y3fl0q8kqxbsqj9snyg7spaqj09xid9rfza7l5zpk8p0ajqnmk"
|
||||
"version": "v0.181.31",
|
||||
"commit-sha1": "6e056348e6d28f962167118612826f1ef0e47b22",
|
||||
"src-sha256": "1qvfwk28sg93basjzy8r55qz8pk9xg0h7kxv5ykxkbfh4q17a1ns"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user