From a3cb83726696dffee33f6800fb2fda1bab86cb68 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Mon, 31 May 2021 17:06:15 +0200 Subject: [PATCH] Fix group chat gaps --- src/status_im/chat/db.cljs | 17 ++++++++++------- src/status_im/subs.cljs | 14 +++++++++++--- status-go-version.json | 6 +++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/status_im/chat/db.cljs b/src/status_im/chat/db.cljs index 0a335e350c..dc67b89e4c 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 chat-type] + [messages chat-id synced-from chat-type joined loading-messages?] (let [messages-with-gaps (reduce (fn [acc {:keys [gap-parameters message-id] :as message}] (let [last-element (peek acc)] @@ -81,10 +81,13 @@ (conj acc (assoc message :gap-ids #{message-id}))))) [] 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 + (if (or loading-messages? ; it's loading messages from the database + (nil? synced-from) ; it's still syncing + (= constants/timeline-chat-type chat-type) ; it's a timeline chat + (= constants/profile-chat-type chat-type) ; it's a profile chat + (and (= constants/private-group-chat-type chat-type) ; it's a private group chat + (or (not (pos? joined)) ; we haven't joined + (>= (quot joined 1000) synced-from))) ; the history goes before we joined + (:gap-ids (peek messages-with-gaps))) ; there's already a gap on top of the chat history + messages-with-gaps ; don't add an extra gap (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 5107f8fd9f..06ceceea06 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -787,6 +787,13 @@ (fn [{:keys [chat-type]}] chat-type)) +(re-frame/reg-sub + :chats/joined + (fn [[_ chat-id] _] + (re-frame/subscribe [:chat-by-id chat-id])) + (fn [{:keys [joined]}] + joined)) + (re-frame/reg-sub :chats/synced-to-and-from (fn [[_ chat-id] _] @@ -957,8 +964,9 @@ (re-frame/subscribe [:chats/chat-messages chat-id]) (re-frame/subscribe [:chats/loading-messages? 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]] + (re-frame/subscribe [:chats/chat-type chat-id]) + (re-frame/subscribe [:chats/joined chat-id])]) + (fn [[message-list 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 @@ -967,7 +975,7 @@ (-> message-list-seq (chat.db/add-datemarks) (hydrate-messages messages) - (chat.db/collapse-gaps chat-id synced-from chat-type)))))) + (chat.db/collapse-gaps chat-id synced-from chat-type joined loading-messages?)))))) ;;we want to keep data unchanged so react doesn't change component when we leave screen (def memo-chat-messages-stream (atom nil)) diff --git a/status-go-version.json b/status-go-version.json index a51955bb8d..1473a90209 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.79.6", - "commit-sha1": "c74c9eedfd16ba06d6076b79f87e4401b19ab621", - "src-sha256": "1g0z0inr8qp2964xkas4365d8v9shh9c8mwrbhhrkdd1yl6ggy4b" + "version": "feature/allow-set-mailserver-sync-value", + "commit-sha1": "26a367c8e269a85c278cfa25acfc892f5f4aba54", + "src-sha256": "1wraz35sjiyf2kq1yiga2gda7jvar4fvya1hdg9imfvffpgbs6aq" }