[Fix] Chat list sort in home screen (#15974)

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2023-05-22 20:46:17 +08:00 committed by GitHub
parent e8ced0a714
commit 6975d6ac48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -22,11 +22,12 @@
[_ index]
#js {:length 56 :offset (* 56 index) :index index})
(defn filter-items-by-tab
(defn filter-and-sort-items-by-tab
[tab items]
(if (= tab :tab/groups)
(filter :group-chat items)
(filter :chat-id items)))
(let [key (if (= tab :tab/groups) :group-chat :chat-id)]
(->> items
(filter key)
(sort-by :timestamp >))))
(defn welcome-blank-chats
[]
@ -38,7 +39,7 @@
(defn chats
[selected-tab top]
(let [unfiltered-items (rf/sub [:chats-stack-items])
items (filter-items-by-tab selected-tab unfiltered-items)]
items (filter-and-sort-items-by-tab selected-tab unfiltered-items)]
(if (empty? items)
[welcome-blank-chats]
[rn/flat-list