Show all users in group chat members list
This commit is contained in:
parent
b18d6b06c7
commit
97083f31f6
|
@ -2,7 +2,8 @@
|
||||||
(:require [clojure.string :as string]
|
(:require [clojure.string :as string]
|
||||||
[re-frame.core :refer [reg-sub subscribe]]
|
[re-frame.core :refer [reg-sub subscribe]]
|
||||||
[status-im.utils.ethereum.core :as ethereum]
|
[status-im.utils.ethereum.core :as ethereum]
|
||||||
[status-im.utils.identicon :as identicon]))
|
[status-im.utils.identicon :as identicon]
|
||||||
|
[status-im.utils.contacts :as utils.contacts]))
|
||||||
|
|
||||||
(reg-sub :get-current-contact-identity :contacts/identity)
|
(reg-sub :get-current-contact-identity :contacts/identity)
|
||||||
|
|
||||||
|
@ -91,9 +92,22 @@
|
||||||
:<- [:query-current-chat-contacts remove]
|
:<- [:query-current-chat-contacts remove]
|
||||||
identity)
|
identity)
|
||||||
|
|
||||||
|
(defn get-all-contacts-in-group-chat [chat-contact-ids group-admin-id contacts current-account]
|
||||||
|
(let [participant-set (into #{} (filter identity) (conj chat-contact-ids group-admin-id))
|
||||||
|
current-account-contact (-> current-account
|
||||||
|
(select-keys [:name :photo-path :public-key])
|
||||||
|
(clojure.set/rename-keys {:public-key :whisper-identity}))
|
||||||
|
all-contacts (assoc contacts (:whisper-identity current-account-contact) current-account-contact)]
|
||||||
|
(map #(or (get all-contacts %)
|
||||||
|
(utils.contacts/whisper-id->new-contact %))
|
||||||
|
participant-set)))
|
||||||
|
|
||||||
(reg-sub :get-current-chat-contacts
|
(reg-sub :get-current-chat-contacts
|
||||||
:<- [:query-current-chat-contacts filter]
|
:<- [:get-current-chat]
|
||||||
identity)
|
:<- [:get-contacts]
|
||||||
|
:<- [:get-current-account]
|
||||||
|
(fn [[{:keys [contacts group-admin]} all-contacts current-account]]
|
||||||
|
(get-all-contacts-in-group-chat contacts group-admin all-contacts current-account)))
|
||||||
|
|
||||||
(reg-sub :get-contacts-by-chat
|
(reg-sub :get-contacts-by-chat
|
||||||
(fn [[_ _ chat-id] _]
|
(fn [[_ _ chat-id] _]
|
||||||
|
|
|
@ -71,29 +71,30 @@
|
||||||
{:action #(re-frame/dispatch [:remove-group-chat-participants #{(:whisper-identity contact)}])
|
{:action #(re-frame/dispatch [:remove-group-chat-participants #{(:whisper-identity contact)}])
|
||||||
:label (i18n/label :t/remove-from-chat)}])
|
:label (i18n/label :t/remove-from-chat)}])
|
||||||
|
|
||||||
(defn render-contact [contact admin?]
|
(defn render-contact [{:keys [name whisper-identity] :as contact} admin? group-admin-identity current-user-identity]
|
||||||
[react/view
|
[react/view
|
||||||
[contact/contact-view
|
[contact/contact-view
|
||||||
{:contact contact
|
{:contact contact
|
||||||
:extend-options (contact-actions contact)
|
:extend-options (contact-actions contact)
|
||||||
:extend-title (:name contact)
|
:extend-title name
|
||||||
:extended? admin?
|
:extended? (and admin? (not= whisper-identity group-admin-identity))
|
||||||
:accessibility-label :member-item
|
:accessibility-label :member-item
|
||||||
:inner-props {:accessibility-label :member-name-text}
|
:inner-props {:accessibility-label :member-name-text}
|
||||||
:on-press #(re-frame/dispatch [:show-profile (:whisper-identity contact)])}]])
|
:on-press (when (not= whisper-identity current-user-identity)
|
||||||
|
#(re-frame/dispatch [:show-profile whisper-identity]))}]])
|
||||||
|
|
||||||
(defview chat-group-contacts-view [admin?]
|
(defview chat-group-contacts-view [admin? group-admin-identity current-user-identity]
|
||||||
(letsubs [contacts [:get-current-chat-contacts]]
|
(letsubs [contacts [:get-current-chat-contacts]]
|
||||||
[react/view
|
[react/view
|
||||||
[list/flat-list {:data contacts
|
[list/flat-list {:data contacts
|
||||||
:separator list/default-separator
|
:separator list/default-separator
|
||||||
:key-fn :address
|
:key-fn :address
|
||||||
:render-fn #(render-contact % admin?)}]]))
|
:render-fn #(render-contact % admin? group-admin-identity current-user-identity)}]]))
|
||||||
|
|
||||||
(defn members-list [admin?]
|
(defn members-list [admin? group-admin-identity current-user-identity]
|
||||||
[react/view
|
[react/view
|
||||||
[profile.components/settings-title (i18n/label :t/members-title)]
|
[profile.components/settings-title (i18n/label :t/members-title)]
|
||||||
[chat-group-contacts-view admin?]])
|
[chat-group-contacts-view admin? group-admin-identity current-user-identity]])
|
||||||
|
|
||||||
(defview group-chat-profile []
|
(defview group-chat-profile []
|
||||||
(letsubs [{:keys [group-admin] :as current-chat} [:get-current-chat]
|
(letsubs [{:keys [group-admin] :as current-chat} [:get-current-chat]
|
||||||
|
@ -116,4 +117,4 @@
|
||||||
:action-label-style styles/action-label
|
:action-label-style styles/action-label
|
||||||
:action-separator-style styles/action-separator
|
:action-separator-style styles/action-separator
|
||||||
:icon-opts styles/action-icon-opts}]
|
:icon-opts styles/action-icon-opts}]
|
||||||
[members-list admin?]]]])))
|
[members-list admin? group-admin current-pk]]]])))
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
(ns status-im.test.contacts.subs
|
||||||
|
(:require [cljs.test :refer-macros [deftest is testing]]
|
||||||
|
[status-im.ui.screens.contacts.subs :as contacts-subs]))
|
||||||
|
|
||||||
|
(deftest contacts-subs
|
||||||
|
(testing "get-all-contacts-in-group-chat"
|
||||||
|
(let [chat-contact-ids ["0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"
|
||||||
|
"0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"]
|
||||||
|
group-admin-id "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
|
||||||
|
contacts {"demo-bot"
|
||||||
|
{:description nil,
|
||||||
|
:last-updated 0,
|
||||||
|
:hide-contact? false,
|
||||||
|
:address nil,
|
||||||
|
:name "Demo bot",
|
||||||
|
:jail-loaded? true,
|
||||||
|
:fcm-token nil,
|
||||||
|
:dapp-url nil,
|
||||||
|
:dapp-hash nil,
|
||||||
|
:photo-path nil,
|
||||||
|
:debug? false,
|
||||||
|
:status nil,
|
||||||
|
:bot-url "local://demo-bot",
|
||||||
|
:pending? false,
|
||||||
|
:whisper-identity "demo-bot",
|
||||||
|
:last-online 0,
|
||||||
|
:dapp? true,
|
||||||
|
:public-key nil},
|
||||||
|
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
|
||||||
|
{:description nil,
|
||||||
|
:last-updated 0,
|
||||||
|
:hide-contact? false,
|
||||||
|
:address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc",
|
||||||
|
:name "User B",
|
||||||
|
:fcm-token nil,
|
||||||
|
:dapp-url nil,
|
||||||
|
:dapp-hash nil,
|
||||||
|
:photo-path "photo1",
|
||||||
|
:debug? false,
|
||||||
|
:status nil,
|
||||||
|
:bot-url nil,
|
||||||
|
:pending? true,
|
||||||
|
:whisper-identity
|
||||||
|
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f",
|
||||||
|
:last-online 0,
|
||||||
|
:dapp? false,
|
||||||
|
:public-key
|
||||||
|
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"},
|
||||||
|
"cryptokitties"
|
||||||
|
{:description "Collect and breed adorable digital cats.",
|
||||||
|
:last-updated 0,
|
||||||
|
:hide-contact? false,
|
||||||
|
:address nil,
|
||||||
|
:name "CryptoKitties",
|
||||||
|
:fcm-token nil,
|
||||||
|
:dapp-url "https://www.cryptokitties.co",
|
||||||
|
:dapp-hash nil,
|
||||||
|
:photo-path "contacts://cryptokitties",
|
||||||
|
:debug? false,
|
||||||
|
:status nil,
|
||||||
|
:bot-url nil,
|
||||||
|
:pending? false,
|
||||||
|
:whisper-identity "cryptokitties",
|
||||||
|
:last-online 0,
|
||||||
|
:dapp? true,
|
||||||
|
:public-key nil}}
|
||||||
|
current-account {:last-updated 0,
|
||||||
|
:address "f23d28f538fd8cd4a90c2d96ca89f5bccca5383f",
|
||||||
|
:email nil,
|
||||||
|
:signed-up? true,
|
||||||
|
:sharing-usage-data? false,
|
||||||
|
:name "User A",
|
||||||
|
:photo-path "photo2",
|
||||||
|
:public-key
|
||||||
|
"0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}]
|
||||||
|
(is (= (contacts-subs/get-all-contacts-in-group-chat chat-contact-ids
|
||||||
|
group-admin-id
|
||||||
|
contacts
|
||||||
|
current-account)
|
||||||
|
[{:name "Snappy Impressive Leonberger", :photo-path "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAADAFBMVEXw8PCx2IwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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UVORK5CYII=", :whisper-identity "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"}
|
||||||
|
{:name "User A", :photo-path "photo2", :whisper-identity "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}
|
||||||
|
{:description nil, :last-updated 0, :hide-contact? false, :address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc", :name "User B", :fcm-token nil, :dapp-url nil, :dapp-hash nil, :photo-path "photo1", :debug? false, :status nil, :bot-url nil, :pending? true, :whisper-identity "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f", :last-online 0, :dapp? false, :public-key "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}])))))
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [doo.runner :refer-macros [doo-tests]]
|
(:require [doo.runner :refer-macros [doo-tests]]
|
||||||
[status-im.test.chat.events]
|
[status-im.test.chat.events]
|
||||||
[status-im.test.contacts.events]
|
[status-im.test.contacts.events]
|
||||||
|
[status-im.test.contacts.subs]
|
||||||
[status-im.test.accounts.events]
|
[status-im.test.accounts.events]
|
||||||
[status-im.test.data-store.realm.core]
|
[status-im.test.data-store.realm.core]
|
||||||
[status-im.test.wallet.transactions.subs]
|
[status-im.test.wallet.transactions.subs]
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
'status-im.test.chat.models
|
'status-im.test.chat.models
|
||||||
'status-im.test.accounts.events
|
'status-im.test.accounts.events
|
||||||
'status-im.test.contacts.events
|
'status-im.test.contacts.events
|
||||||
|
'status-im.test.contacts.subs
|
||||||
'status-im.test.profile.events
|
'status-im.test.profile.events
|
||||||
'status-im.test.data-store.realm.core
|
'status-im.test.data-store.realm.core
|
||||||
'status-im.test.bots.events
|
'status-im.test.bots.events
|
||||||
|
|
Loading…
Reference in New Issue