Fix group chat gaps
This commit is contained in:
parent
ae3df0c730
commit
a3cb837266
|
@ -61,7 +61,7 @@
|
||||||
"collapse-gaps will take an array of messages and collapse any gap next to
|
"collapse-gaps will take an array of messages and collapse any gap next to
|
||||||
each other in a single gap.
|
each other in a single gap.
|
||||||
It will also append one last gap if the last message is a non-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
|
(let [messages-with-gaps (reduce
|
||||||
(fn [acc {:keys [gap-parameters message-id] :as message}]
|
(fn [acc {:keys [gap-parameters message-id] :as message}]
|
||||||
(let [last-element (peek acc)]
|
(let [last-element (peek acc)]
|
||||||
|
@ -81,10 +81,13 @@
|
||||||
(conj acc (assoc message :gap-ids #{message-id})))))
|
(conj acc (assoc message :gap-ids #{message-id})))))
|
||||||
[]
|
[]
|
||||||
messages)]
|
messages)]
|
||||||
;; If it's a gap or the chat is still syncing, do nothing
|
(if (or loading-messages? ; it's loading messages from the database
|
||||||
(if (or (nil? synced-from)
|
(nil? synced-from) ; it's still syncing
|
||||||
(= constants/timeline-chat-type chat-type)
|
(= constants/timeline-chat-type chat-type) ; it's a timeline chat
|
||||||
(= constants/profile-chat-type chat-type)
|
(= constants/profile-chat-type chat-type) ; it's a profile chat
|
||||||
(:gap-ids (peek messages-with-gaps)))
|
(and (= constants/private-group-chat-type chat-type) ; it's a private group chat
|
||||||
messages-with-gaps
|
(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)))))
|
(conj messages-with-gaps (last-gap chat-id synced-from)))))
|
||||||
|
|
|
@ -787,6 +787,13 @@
|
||||||
(fn [{:keys [chat-type]}]
|
(fn [{:keys [chat-type]}]
|
||||||
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
|
(re-frame/reg-sub
|
||||||
:chats/synced-to-and-from
|
:chats/synced-to-and-from
|
||||||
(fn [[_ chat-id] _]
|
(fn [[_ chat-id] _]
|
||||||
|
@ -957,8 +964,9 @@
|
||||||
(re-frame/subscribe [:chats/chat-messages chat-id])
|
(re-frame/subscribe [:chats/chat-messages chat-id])
|
||||||
(re-frame/subscribe [:chats/loading-messages? chat-id])
|
(re-frame/subscribe [:chats/loading-messages? chat-id])
|
||||||
(re-frame/subscribe [:chats/synced-from chat-id])
|
(re-frame/subscribe [:chats/synced-from chat-id])
|
||||||
(re-frame/subscribe [:chats/chat-type 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/joined chat-id])])
|
||||||
|
(fn [[message-list messages loading-messages? synced-from chat-type joined] [_ chat-id]]
|
||||||
;;TODO (perf)
|
;;TODO (perf)
|
||||||
(let [message-list-seq (models.message-list/->seq message-list)]
|
(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
|
||||||
|
@ -967,7 +975,7 @@
|
||||||
(-> message-list-seq
|
(-> message-list-seq
|
||||||
(chat.db/add-datemarks)
|
(chat.db/add-datemarks)
|
||||||
(hydrate-messages messages)
|
(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
|
;;we want to keep data unchanged so react doesn't change component when we leave screen
|
||||||
(def memo-chat-messages-stream (atom nil))
|
(def memo-chat-messages-stream (atom nil))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.79.6",
|
"version": "feature/allow-set-mailserver-sync-value",
|
||||||
"commit-sha1": "c74c9eedfd16ba06d6076b79f87e4401b19ab621",
|
"commit-sha1": "26a367c8e269a85c278cfa25acfc892f5f4aba54",
|
||||||
"src-sha256": "1g0z0inr8qp2964xkas4365d8v9shh9c8mwrbhhrkdd1yl6ggy4b"
|
"src-sha256": "1wraz35sjiyf2kq1yiga2gda7jvar4fvya1hdg9imfvffpgbs6aq"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue