From ff2590a40fe5911b5ad7cae7586347e7bb385da1 Mon Sep 17 00:00:00 2001 From: Pawel Kapala Date: Wed, 13 Oct 2021 00:46:20 +0200 Subject: [PATCH] Filter moved from view to the subscription --- src/status_im/subs.cljs | 13 ++++++++----- src/status_im/ui/screens/chat/views.cljs | 4 +--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index 1abdd4b897..37cfd33c3d 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -1103,13 +1103,16 @@ (fn [[message-list messages pin-messages loading-messages? synced-from chat-type joined] [_ chat-id]] ;;TODO (perf) (let [message-list-seq (models.message-list/->seq message-list)] - ; Don't show gaps if that's the case as we are still loading messages + ; Don't show gaps if that's the case as we are still loading messages (if (and (empty? message-list-seq) loading-messages?) [] - (-> message-list-seq - (chat.db/add-datemarks) - (hydrate-messages messages pin-messages) - (chat.db/collapse-gaps chat-id synced-from (datetime/timestamp) chat-type joined loading-messages?)))))) + (->> + (-> message-list-seq + (chat.db/add-datemarks) + (hydrate-messages messages pin-messages) + (chat.db/collapse-gaps chat-id synced-from (datetime/timestamp) chat-type joined loading-messages?)) + ;; remove when the issue with messages-view chat list-key-fn is fixed + (filter (fn [message] (some? (:message-id message))))))))) (re-frame/reg-sub :chats/raw-chat-pin-messages-stream diff --git a/src/status_im/ui/screens/chat/views.cljs b/src/status_im/ui/screens/chat/views.cljs index a290b2af38..7440d9fe99 100644 --- a/src/status_im/ui/screens/chat/views.cljs +++ b/src/status_im/ui/screens/chat/views.cljs @@ -306,9 +306,7 @@ (defn messages-view [{:keys [chat bottom-space pan-responder space-keeper show-input?]}] (let [{:keys [group-chat chat-id public? community-id admins]} chat - messages (->> @(re-frame/subscribe [:chats/chat-messages-stream chat-id]) - ;; remove when the issue with key-fn is fixed - (filter (fn [message] (some? (:message-id message)))))] + messages @(re-frame/subscribe [:chats/chat-messages-stream chat-id])] ;;do not use anonymous functions for handlers (when (seq messages) [list/bidi-flat-list