[fix 6500] search doesn't find name for contact that added user
- chat name is not updated with contact name - when a contact adds the user and is added back by user, the name of the chat is still the random name of the contact - in active-chats subscriptions, replace the name of the chat by the current name of the contact
This commit is contained in:
parent
6d0a7219ae
commit
e020f19da0
|
@ -80,7 +80,10 @@
|
|||
(reduce (fn [acc [chat-id {:keys [is-active] :as chat}]]
|
||||
(if is-active
|
||||
(assoc acc chat-id (if-let [contact (get contacts chat-id)]
|
||||
(update chat :tags clojure.set/union (:tags contact))
|
||||
(-> chat
|
||||
(assoc :name (:name contact))
|
||||
(assoc :random-name (gfycat/generate-gfy (:whisper-identity contact)))
|
||||
(update :tags clojure.set/union (:tags contact)))
|
||||
chat))
|
||||
acc))
|
||||
{}
|
||||
|
|
|
@ -7,19 +7,25 @@
|
|||
(fn [db]
|
||||
(get-in db [:ui/search :filter] "")))
|
||||
|
||||
(defn filter-chats
|
||||
[[chats search-filter]]
|
||||
(if (empty? search-filter)
|
||||
chats
|
||||
(let [search-filter (string/lower-case search-filter)]
|
||||
(keep #(let [{:keys [name random-name tags]} (val %)]
|
||||
(when (some (fn [s]
|
||||
(when s
|
||||
(string/includes? (string/lower-case s)
|
||||
search-filter)))
|
||||
(into [name random-name] tags))
|
||||
%))
|
||||
chats))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:search/filtered-active-chats
|
||||
:<- [:get-active-chats]
|
||||
:<- [:search/filter]
|
||||
(fn [[chats tag-filter]]
|
||||
(if (empty? tag-filter)
|
||||
chats
|
||||
(keep #(when (some (fn [tag]
|
||||
(string/includes? (string/lower-case tag)
|
||||
(string/lower-case tag-filter)))
|
||||
(into [(:name (val %))] (:tags (val %))))
|
||||
%)
|
||||
chats))))
|
||||
filter-chats)
|
||||
|
||||
(re-frame/reg-sub
|
||||
:search/filtered-home-items
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
[status-im.test.models.contact]
|
||||
[status-im.test.models.network]
|
||||
[status-im.test.models.wallet]
|
||||
[status-im.test.search.core]
|
||||
[status-im.test.transport.core]
|
||||
[status-im.test.transport.inbox]
|
||||
[status-im.test.chat.models]
|
||||
|
@ -96,6 +97,7 @@
|
|||
'status-im.test.chat.commands.input
|
||||
'status-im.test.chat.commands.impl.transactions
|
||||
'status-im.test.i18n
|
||||
'status-im.test.search.core
|
||||
'status-im.test.transport.core
|
||||
'status-im.test.transport.inbox
|
||||
'status-im.test.protocol.web3.inbox
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
(ns status-im.test.search.core
|
||||
(:require [cljs.test :refer-macros [deftest testing is]]
|
||||
[status-im.search.subs :as search.subs]))
|
||||
|
||||
(deftest filter-chats
|
||||
(let [chats {:chat-1 {:name "name1"
|
||||
:random-name "random-name1"
|
||||
:tags #{"tag1"}}
|
||||
:chat-2 {:name "name2"
|
||||
:random-name "random-name2"
|
||||
:tags #{"tag2" "tag3"}}
|
||||
:chat-3 {:name "name3"
|
||||
:random-name "random-name3"
|
||||
:tags #{}}
|
||||
:chat-4 {:name "name4"
|
||||
:random-name "random-name4"
|
||||
:tags #{"tag4"}}}]
|
||||
(testing "no search filter"
|
||||
(is (= 4 (count (search.subs/filter-chats [chats ""])))))
|
||||
(testing "searching for a specific tag"
|
||||
(is (= 1 (count (search.subs/filter-chats [chats "tag2"])))))
|
||||
(testing "searching for a partial tag"
|
||||
(is (= 3 (count (search.subs/filter-chats [chats "tag"])))))
|
||||
(testing "searching for a specific random-name"
|
||||
(is (= 1 (count (search.subs/filter-chats [chats "random-name1"])))))
|
||||
(testing "searching for a partial random-name"
|
||||
(is (= 4 (count (search.subs/filter-chats [chats "random-name"])))))
|
||||
(testing "searching for a specific chat name"
|
||||
(is (= 1 (count (search.subs/filter-chats [chats "name4"])))))))
|
Loading…
Reference in New Issue