Filter moved from view to the subscription

This commit is contained in:
Pawel Kapala 2021-10-13 00:46:20 +02:00 committed by Andrea Maria Piana
parent 483277d2bd
commit ff2590a40f
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
2 changed files with 9 additions and 8 deletions

View File

@ -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

View File

@ -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