Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de2d17c3d2 |
@@ -9,10 +9,12 @@
|
||||
[quo/divider-label {:label title}])
|
||||
|
||||
(defn contact-list
|
||||
[data]
|
||||
(let [contacts (if (:group data)
|
||||
(rf/sub [:contacts/grouped-by-first-letter])
|
||||
(rf/sub [:contacts/filtered-active-sections]))]
|
||||
[{:keys [start-a-new-chat?] :as data}]
|
||||
(let [contacts (if start-a-new-chat?
|
||||
(rf/sub [:contacts/sorted-and-grouped-by-first-letter])
|
||||
(if (:group data)
|
||||
(rf/sub [:contacts/grouped-by-first-letter])
|
||||
(rf/sub [:contacts/filtered-active-sections])))]
|
||||
[rn/section-list
|
||||
{:key-fn :title
|
||||
:sticky-section-headers-enabled false
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
[status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.utils.image-server :as image-server]
|
||||
[utils.collection]))
|
||||
[utils.collection]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::query-current-chat-contacts
|
||||
@@ -102,6 +103,23 @@
|
||||
sort
|
||||
vals)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:contacts/sorted-and-grouped-by-first-letter
|
||||
:<- [:contacts/active]
|
||||
:<- [:selected-contacts-count]
|
||||
(fn [[contacts selected-contacts-count]]
|
||||
(->> contacts
|
||||
(filter :mutual?)
|
||||
(map #(assoc %
|
||||
:allow-new-users?
|
||||
(< selected-contacts-count
|
||||
(dec constants/max-group-chat-participants))))
|
||||
(group-by (comp (fnil string/upper-case "") first :alias))
|
||||
(sort-by (fn [[title]] title))
|
||||
(map (fn [[title data]]
|
||||
{:title title
|
||||
:data data})))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:contacts/sorted-contacts
|
||||
:<- [:contacts/active]
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
(ns status-im2.subs.contact-test
|
||||
(:require [cljs.test :refer [is testing]]
|
||||
[re-frame.db :as rf-db]
|
||||
[test-helpers.unit :as h]
|
||||
status-im2.subs.contact
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def ^:private contacts-sample-data
|
||||
{:selected-contacts-count 1
|
||||
:contacts/contacts {"0xtest" {:last-updated 1672582629695
|
||||
:mutual? true
|
||||
:contactRequestClock 0
|
||||
:images {}
|
||||
:added true
|
||||
:name "slim.shady"
|
||||
:Removed false
|
||||
:trustStatus 0
|
||||
:alias "Real Slim Shady"
|
||||
:bio ""
|
||||
:IsSyncing false
|
||||
:display-name ""
|
||||
:ens-verified true
|
||||
:socialLinks nil
|
||||
:blocked false
|
||||
:verificationStatus 0
|
||||
:lastUpdatedLocally 1672582563204
|
||||
:public-key "0xtest"
|
||||
:has-added-us true
|
||||
:contact-request-state 1}
|
||||
"0xtest2" {:last-updated 1672582629695
|
||||
:mutual? true
|
||||
:contactRequestClock 0
|
||||
:images {}
|
||||
:added true
|
||||
:name "slim.shady"
|
||||
:Removed false
|
||||
:trustStatus 0
|
||||
:alias "Fake Slim Shady"
|
||||
:bio ""
|
||||
:IsSyncing false
|
||||
:display-name ""
|
||||
:ens-verified true
|
||||
:socialLinks nil
|
||||
:blocked false
|
||||
:verificationStatus 0
|
||||
:lastUpdatedLocally 1672582563204
|
||||
:public-key "0xtest"
|
||||
:has-added-us true
|
||||
:contact-request-state 1}
|
||||
"0xtest3" {:last-updated 1672582629695
|
||||
:mutual? true
|
||||
:contactRequestClock 0
|
||||
:images {}
|
||||
:added true
|
||||
:name "slim.shady"
|
||||
:Removed false
|
||||
:trustStatus 0
|
||||
:alias "Instant noodles"
|
||||
:bio ""
|
||||
:IsSyncing false
|
||||
:display-name ""
|
||||
:ens-verified true
|
||||
:socialLinks nil
|
||||
:blocked false
|
||||
:verificationStatus 0
|
||||
:lastUpdatedLocally 1672582563204
|
||||
:public-key "0xtest"
|
||||
:has-added-us true
|
||||
:contact-request-state 1}}})
|
||||
|
||||
(def ^:private expected-sorted-contacts
|
||||
'({:title "F"
|
||||
:data ({:active? true
|
||||
:last-updated 1672582629695
|
||||
:mutual? true
|
||||
:blocked? false
|
||||
:contactRequestClock 0
|
||||
:images {}
|
||||
:added true
|
||||
:name "slim.shady"
|
||||
:added? true
|
||||
:Removed false
|
||||
:trustStatus 0
|
||||
:alias "Fake Slim Shady"
|
||||
:bio ""
|
||||
:IsSyncing false
|
||||
:display-name ""
|
||||
:ens-verified true
|
||||
:socialLinks nil
|
||||
:blocked false
|
||||
:allow-new-users? true
|
||||
:verificationStatus 0
|
||||
:lastUpdatedLocally 1672582563204
|
||||
:public-key "0xtest"
|
||||
:names {:nickname nil
|
||||
:display-name ""
|
||||
:three-words-name "Fake Slim Shady"
|
||||
:ens-name "@slim.shady"}
|
||||
:has-added-us true
|
||||
:contact-request-state 1})}
|
||||
{:title "I"
|
||||
:data ({:active? true
|
||||
:last-updated 1672582629695
|
||||
:mutual? true
|
||||
:blocked? false
|
||||
:contactRequestClock 0
|
||||
:images {}
|
||||
:added true
|
||||
:name "slim.shady"
|
||||
:added? true
|
||||
:Removed false
|
||||
:trustStatus 0
|
||||
:alias "Instant noodles"
|
||||
:bio ""
|
||||
:IsSyncing false
|
||||
:display-name ""
|
||||
:ens-verified true
|
||||
:socialLinks nil
|
||||
:blocked false
|
||||
:allow-new-users? true
|
||||
:verificationStatus 0
|
||||
:lastUpdatedLocally 1672582563204
|
||||
:public-key "0xtest"
|
||||
:names {:nickname nil
|
||||
:display-name ""
|
||||
:three-words-name "Instant noodles"
|
||||
:ens-name "@slim.shady"}
|
||||
:has-added-us true
|
||||
:contact-request-state 1})}
|
||||
{:title "R"
|
||||
:data ({:active? true
|
||||
:last-updated 1672582629695
|
||||
:mutual? true
|
||||
:blocked? false
|
||||
:contactRequestClock 0
|
||||
:images {}
|
||||
:added true
|
||||
:name "slim.shady"
|
||||
:added? true
|
||||
:Removed false
|
||||
:trustStatus 0
|
||||
:alias "Real Slim Shady"
|
||||
:bio ""
|
||||
:IsSyncing false
|
||||
:display-name ""
|
||||
:ens-verified true
|
||||
:socialLinks nil
|
||||
:blocked false
|
||||
:allow-new-users? true
|
||||
:verificationStatus 0
|
||||
:lastUpdatedLocally 1672582563204
|
||||
:public-key "0xtest"
|
||||
:names {:nickname nil
|
||||
:display-name ""
|
||||
:three-words-name "Real Slim Shady"
|
||||
:ens-name "@slim.shady"}
|
||||
:has-added-us true
|
||||
:contact-request-state 1})}))
|
||||
|
||||
(h/deftest-sub :contacts/sorted-and-grouped-by-first-letter
|
||||
[sub-name]
|
||||
(testing "Returning empty sequence when no contacts"
|
||||
(swap! rf-db/app-db merge (assoc contacts-sample-data :contacts/contacts {}))
|
||||
(is (empty? (rf/sub [sub-name]))))
|
||||
(testing "Returning empty sequence when no mutual contacts"
|
||||
(let [remove-contact-as-mutual #(-> %
|
||||
(assoc-in ["0xtest" :mutual?] false)
|
||||
(assoc-in ["0xtest2" :mutual?] false)
|
||||
(assoc-in ["0xtest3" :mutual?] false))]
|
||||
(swap! rf-db/app-db merge
|
||||
(update contacts-sample-data :contacts/contacts remove-contact-as-mutual))
|
||||
(is (empty? (rf/sub [sub-name])))))
|
||||
(testing "Returning sorted contacts"
|
||||
(swap! rf-db/app-db merge contacts-sample-data)
|
||||
(let [contact-list-without-identicons (map (fn [contact-group]
|
||||
(update contact-group
|
||||
:data
|
||||
#(map (fn [contact]
|
||||
(dissoc contact :identicon))
|
||||
%)))
|
||||
(rf/sub [sub-name]))]
|
||||
|
||||
(is (= expected-sorted-contacts contact-list-without-identicons)))))
|
||||
@@ -1494,7 +1494,7 @@
|
||||
"not-enough-snt": "Not enough SNT",
|
||||
"add-new-contact": "Add new contact",
|
||||
"add-a-contact": "Add a contact",
|
||||
"enter-a-chat-key": "Enter a chat key or scan a QR",
|
||||
"enter-a-chat-key": "Add a chatkey or scan a QR",
|
||||
"you-dont-have-contacts": "You don’t have any contacts yet.",
|
||||
"set-max": "Set max",
|
||||
"continue-anyway": "Continue anyway",
|
||||
@@ -1941,5 +1941,8 @@
|
||||
"contact-request-chat-pending": "Your contact request is pending",
|
||||
"contact-request-chat-add": "Add {{name}} to send a message",
|
||||
"join-request": "Join request",
|
||||
"wants-to-join": "wants to join"
|
||||
"wants-to-join": "wants to join",
|
||||
"connect-with-users": "Connect with users",
|
||||
"invite-friends-and-family": "Invite your friends and family to Status",
|
||||
"you-have-no-contacts": "You have no contacts"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user