[Fixes #9510] Fix timestamp placement for text elements

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-12-02 09:00:06 +01:00
parent 5bb6997d1d
commit 7bf626c3a3
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
1 changed files with 12 additions and 3 deletions

View File

@ -139,9 +139,18 @@
outgoing] :as message}
tree]
(conj (reduce (fn [acc e] (render-block message acc e)) [react/view {}] tree)
[react/text {:style (style/message-timestamp-placeholder outgoing)}
(str " " timestamp-str)]))
(let [elements (reduce (fn [acc e] (render-block message acc e)) [react/view {}] tree)
timestamp [react/text {:style (style/message-timestamp-placeholder outgoing)}
(str " " timestamp-str)]
last-element (peek elements)]
;; Using `nth` here as slightly faster than `first`, roughly 30%
;; It's worth considering pure js structures for this code path as
;; it's perfomance critical
(if (= react/text-class (nth last-element 0))
;; Append timestamp to last text
(conj (pop elements) (conj last-element timestamp))
;; Append timestamp to new block
(conj elements timestamp))))
(defn text-message
[{:keys [chat-id message-id content