From d6a999043e4891952ad855d531ae297dc63da2ee Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Mon, 31 May 2021 12:58:17 +0200 Subject: [PATCH] dont show gaps in timeline/profile chats --- src/status_im/chat/db.cljs | 4 +++- src/status_im/subs.cljs | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/status_im/chat/db.cljs b/src/status_im/chat/db.cljs index 57575f4418..0a335e350c 100644 --- a/src/status_im/chat/db.cljs +++ b/src/status_im/chat/db.cljs @@ -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))))) diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index f645c60164..7b65b30ad6 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -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))