From 6975d6ac4832abe7591a75bd1adebd5eb3c2fa5b Mon Sep 17 00:00:00 2001 From: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> Date: Mon, 22 May 2023 20:46:17 +0800 Subject: [PATCH] [Fix] Chat list sort in home screen (#15974) Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> --- src/status_im2/contexts/chat/home/view.cljs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/status_im2/contexts/chat/home/view.cljs b/src/status_im2/contexts/chat/home/view.cljs index f91b27279c..45791d21ac 100644 --- a/src/status_im2/contexts/chat/home/view.cljs +++ b/src/status_im2/contexts/chat/home/view.cljs @@ -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