Fix for sender's name, profile icon, chat key, timestamp being lost for messages that contain images (#15426)
* Fix for sender's name, profile icon, chat key, timestamp being lost for messages that contain images Lint fix Lint fix * Lint fix * Text fix
This commit is contained in:
parent
401f7d7383
commit
8d166a3a52
|
@ -19,17 +19,17 @@
|
||||||
so we bucket both in 1999-12-31"
|
so we bucket both in 1999-12-31"
|
||||||
[{:keys [acc last-timestamp last-datemark]} {:keys [whisper-timestamp datemark] :as msg}]
|
[{:keys [acc last-timestamp last-datemark]} {:keys [whisper-timestamp datemark] :as msg}]
|
||||||
(cond
|
(cond
|
||||||
(empty? acc) ; initial element
|
(empty? acc) ; initial element
|
||||||
{:last-timestamp whisper-timestamp
|
{:last-timestamp whisper-timestamp
|
||||||
:last-datemark datemark
|
:last-datemark datemark
|
||||||
:acc (conj acc msg)}
|
:acc (conj acc msg)}
|
||||||
|
|
||||||
(and (not= last-datemark datemark) ; not the same day
|
(and (not= last-datemark datemark) ; not the same day
|
||||||
(< whisper-timestamp last-timestamp)) ; not out-of-order
|
(< whisper-timestamp last-timestamp)) ; not out-of-order
|
||||||
{:last-timestamp whisper-timestamp
|
{:last-timestamp whisper-timestamp
|
||||||
:last-datemark datemark
|
:last-datemark datemark
|
||||||
:acc (conj acc
|
:acc (conj acc
|
||||||
{:value last-datemark ; intersperse datemark message
|
{:value last-datemark ; intersperse datemark message
|
||||||
:type :datemark}
|
:type :datemark}
|
||||||
msg)}
|
msg)}
|
||||||
:else
|
:else
|
||||||
|
@ -82,17 +82,18 @@
|
||||||
(conj acc (assoc message :gap-ids #{message-id})))))
|
(conj acc (assoc message :gap-ids #{message-id})))))
|
||||||
[]
|
[]
|
||||||
messages)]
|
messages)]
|
||||||
(if (or loading-messages? ; it's loading messages from the database
|
(if (or loading-messages? ; it's loading messages from the database
|
||||||
(nil? synced-from) ; it's still syncing
|
(nil? synced-from) ; it's still syncing
|
||||||
(= constants/timeline-chat-type chat-type) ; it's a timeline chat
|
(= constants/timeline-chat-type chat-type) ; it's a timeline chat
|
||||||
(= constants/profile-chat-type chat-type) ; it's a profile chat
|
(= constants/profile-chat-type chat-type) ; it's a profile chat
|
||||||
(and (not (nil? synced-from)) ; it's not more than a month
|
(and (not (nil? synced-from)) ; it's not more than a month
|
||||||
(<= synced-from (- (quot now 1000) constants/one-month)))
|
(<= synced-from (- (quot now 1000) constants/one-month)))
|
||||||
(and (= constants/private-group-chat-type chat-type) ; it's a private group chat
|
(and (= constants/private-group-chat-type chat-type) ; it's a private group chat
|
||||||
(or (not (pos? joined)) ; we haven't joined
|
(or (not (pos? joined)) ; we haven't joined
|
||||||
(>= (quot joined 1000) synced-from))) ; the history goes before we 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
|
(:gap-ids (peek messages-with-gaps))) ; there's already a gap on top of the chat
|
||||||
messages-with-gaps ; don't add an extra gap
|
; 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)))))
|
||||||
|
|
||||||
(defn hydrate-messages
|
(defn hydrate-messages
|
||||||
|
@ -111,36 +112,31 @@
|
||||||
|
|
||||||
(defn albumize-messages
|
(defn albumize-messages
|
||||||
[messages]
|
[messages]
|
||||||
(get
|
(->> messages
|
||||||
(reduce
|
(reduce
|
||||||
(fn [{:keys [messages albums]} message]
|
(fn [{:keys [messages albums]} message]
|
||||||
(let [{:keys [album-id content quoted-message]} message
|
(let [{:keys [album-id content quoted-message]} message
|
||||||
{:keys [response-to]} content
|
{:keys [response-to]} content
|
||||||
albums (cond-> albums
|
albums (cond-> albums
|
||||||
album-id (update album-id conj message))
|
album-id
|
||||||
messages (if album-id
|
(update album-id conj message))
|
||||||
(conj
|
messages (if album-id
|
||||||
(filterv #(not= album-id (:album-id %))
|
(conj (filterv #(not= album-id (:album-id %))
|
||||||
messages)
|
messages)
|
||||||
{:album (get albums album-id)
|
(merge message
|
||||||
:album-id album-id
|
{:album (get albums album-id)
|
||||||
:albumize? (:albumize? message)
|
:album-id album-id
|
||||||
:message-id (:message-id message)
|
:content {:response-to
|
||||||
:deleted? (:deleted? message)
|
response-to}
|
||||||
:deleted-for-me? (:deleted-for-me? message)
|
:quoted-message quoted-message
|
||||||
:deleted-by (:deleted-by message)
|
:content-type
|
||||||
:from (:from message)
|
constants/content-type-album}))
|
||||||
:timestamp-str (:timestamp-str message)
|
(conj messages message))]
|
||||||
:content {:response-to response-to}
|
{:messages messages
|
||||||
:quoted-message quoted-message
|
:albums albums}))
|
||||||
:content-type constants/content-type-album})
|
{:messages []
|
||||||
(conj messages message))]
|
:albums {}})
|
||||||
{:messages messages
|
:messages))
|
||||||
:albums albums}))
|
|
||||||
{:messages []
|
|
||||||
:albums {}}
|
|
||||||
messages)
|
|
||||||
:messages))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:chats/chat-messages
|
:chats/chat-messages
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
:album-id "abc"
|
:album-id "abc"
|
||||||
:albumize? true
|
:albumize? true
|
||||||
:message-id "0x444"
|
:message-id "0x444"
|
||||||
:deleted? nil
|
|
||||||
:deleted-for-me? nil
|
|
||||||
:deleted-by nil
|
|
||||||
:from :xyz
|
:from :xyz
|
||||||
:timestamp-str "14:00"
|
:timestamp-str "14:00"
|
||||||
:content-type constants/content-type-album}])
|
:content-type constants/content-type-album}])
|
||||||
|
|
Loading…
Reference in New Issue