Add desktop chunks hack

R

Signed-off-by: Vitaliy Vlasov <siphiuel@gmail.com>
This commit is contained in:
Vitaliy Vlasov 2018-12-20 19:21:59 +02:00
parent dd2ff11216
commit 4b74344f4b
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
2 changed files with 24 additions and 1 deletions

View File

@ -3,6 +3,7 @@
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.platform :as platform]
[status-im.i18n :as i18n]
[status-im.constants :as constants]
[status-im.ui.components.react :as react]
[status-im.ui.components.colors :as colors]
[status-im.utils.http :as http]))
@ -49,3 +50,19 @@
[react/text (into {:key idx} (lookup-props text-chunk message kind))
text-chunk]))
render-recipe))
(defn render-chunks-desktop [render-recipe message]
"This fn is only need as a temporary hack
until rn-desktop supports text/number-of-lines property"
(seq (second
(reduce (fn [[total-length acc] [idx [text-chunk kind]]]
(if (< constants/chars-collapse-threshold total-length)
(reduced [total-length acc])
[(+ total-length (count text-chunk))
(conj acc
(if (= :text kind)
text-chunk
[react/text (into {:key idx} (lookup-props text-chunk message kind))
text-chunk]))]))
[0 []]
(map vector (range) render-recipe)))))

View File

@ -119,7 +119,13 @@
[react/text {:style (styles/message-text collapsible? false)
:selectable true
:selection-color colors/blue-light}
message-text]
(if-let [render-recipe (:render-recipe content)]
(apply
(if (and collapsible? (not expanded?))
chat-utils/render-chunks-desktop
chat-utils/render-chunks)
render-recipe message-text)
message-text)]
(when collapsible?
[message/expand-button expanded? chat-id message-id])])]])