dont show gaps in timeline/profile chats
This commit is contained in:
parent
58d994706f
commit
d6a999043e
|
@ -61,7 +61,7 @@
|
|||
"collapse-gaps will take an array of messages and collapse any gap next to
|
||||
each other in a single gap.
|
||||
It will also append one last gap if the last message is a non-gap"
|
||||
[messages chat-id synced-from]
|
||||
[messages chat-id synced-from chat-type]
|
||||
(let [messages-with-gaps (reduce
|
||||
(fn [acc {:keys [gap-parameters message-id] :as message}]
|
||||
(let [last-element (peek acc)]
|
||||
|
@ -83,6 +83,8 @@
|
|||
messages)]
|
||||
;; If it's a gap or the chat is still syncing, do nothing
|
||||
(if (or (nil? synced-from)
|
||||
(= constants/timeline-chat-type chat-type)
|
||||
(= constants/profile-chat-type chat-type)
|
||||
(:gap-ids (peek messages-with-gaps)))
|
||||
messages-with-gaps
|
||||
(conj messages-with-gaps (last-gap chat-id synced-from)))))
|
||||
|
|
|
@ -780,6 +780,13 @@
|
|||
(fn [{:keys [synced-from]}]
|
||||
synced-from))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/chat-type
|
||||
(fn [[_ chat-id] _]
|
||||
(re-frame/subscribe [:chat-by-id chat-id]))
|
||||
(fn [{:keys [chat-type]}]
|
||||
chat-type))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:chats/synced-to-and-from
|
||||
(fn [[_ chat-id] _]
|
||||
|
@ -949,8 +956,9 @@
|
|||
[(re-frame/subscribe [:chats/message-list chat-id])
|
||||
(re-frame/subscribe [:chats/chat-messages chat-id])
|
||||
(re-frame/subscribe [:chats/loading-messages? chat-id])
|
||||
(re-frame/subscribe [:chats/synced-from chat-id])])
|
||||
(fn [[message-list messages loading-messages? synced-from] [_ chat-id]]
|
||||
(re-frame/subscribe [:chats/synced-from chat-id])
|
||||
(re-frame/subscribe [:chats/chat-type chat-id])])
|
||||
(fn [[message-list messages loading-messages? synced-from chat-type] [_ 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
|
||||
|
@ -959,7 +967,7 @@
|
|||
(-> message-list-seq
|
||||
(chat.db/add-datemarks)
|
||||
(hydrate-messages messages)
|
||||
(chat.db/collapse-gaps chat-id synced-from))))))
|
||||
(chat.db/collapse-gaps chat-id synced-from chat-type))))))
|
||||
|
||||
;;we want to keep data unchanged so react doesn't change component when we leave screen
|
||||
(def memo-chat-messages-stream (atom nil))
|
||||
|
|
Loading…
Reference in New Issue