Truncate long chat messages
Fix render-recipes and replies rendering Signed-off-by: Vitaliy Vlasov <siphiuel@gmail.com>
This commit is contained in:
parent
897a8a60b8
commit
b81cb82fc6
|
@ -82,7 +82,7 @@
|
||||||
:font :default}
|
:font :default}
|
||||||
(:text content)]])
|
(:text content)]])
|
||||||
|
|
||||||
(defn- expand-button [expanded? chat-id message-id]
|
(defn expand-button [expanded? chat-id message-id]
|
||||||
[react/text {:style style/message-expand-button
|
[react/text {:style style/message-expand-button
|
||||||
:on-press #(re-frame/dispatch [:chat.ui/message-expand-toggled chat-id message-id])}
|
:on-press #(re-frame/dispatch [:chat.ui/message-expand-toggled chat-id message-id])}
|
||||||
(i18n/label (if expanded? :show-less :show-more))])
|
(i18n/label (if expanded? :show-less :show-more))])
|
||||||
|
|
|
@ -123,12 +123,13 @@
|
||||||
:color color
|
:color color
|
||||||
:margin-bottom 4})
|
:margin-bottom 4})
|
||||||
|
|
||||||
(defn message-text [outgoing]
|
(defn message-text [collapsible? outgoing]
|
||||||
{:color (if outgoing colors/white colors/black)
|
{:color (if outgoing colors/white colors/black)
|
||||||
:font-size 14})
|
:font-size 14
|
||||||
|
:margin-bottom (if collapsible? 2 0)})
|
||||||
|
|
||||||
(defn message-link [outgoing]
|
(defn message-link [outgoing]
|
||||||
(assoc (message-text outgoing)
|
(assoc (message-text false outgoing)
|
||||||
:color (if outgoing colors/white colors/blue)
|
:color (if outgoing colors/white colors/blue)
|
||||||
:text-decoration-line :underline))
|
:text-decoration-line :underline))
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.utils.identicon :as identicon]
|
[status-im.utils.identicon :as identicon]
|
||||||
[status-im.utils.datetime :as time]
|
[status-im.utils.datetime :as time]
|
||||||
|
[status-im.utils.core :as core-utils]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.components.connectivity.view :as connectivity]
|
[status-im.ui.components.connectivity.view :as connectivity]
|
||||||
|
@ -92,13 +93,13 @@
|
||||||
(chat-utils/format-reply-author from username current-public-key)]]
|
(chat-utils/format-reply-author from username current-public-key)]]
|
||||||
[react/text {:style (message.style/quoted-message-text outgoing)
|
[react/text {:style (message.style/quoted-message-text outgoing)
|
||||||
:number-of-lines 5}
|
:number-of-lines 5}
|
||||||
text]]))
|
(core-utils/truncate-str text constants/chars-collapse-threshold)]]))
|
||||||
|
|
||||||
(defn- message-sent? [user-statuses current-public-key]
|
(defn- message-sent? [user-statuses current-public-key]
|
||||||
(not= (get-in user-statuses [current-public-key :status]) :not-sent))
|
(not= (get-in user-statuses [current-public-key :status]) :not-sent))
|
||||||
|
|
||||||
(views/defview message-without-timestamp
|
(views/defview message-without-timestamp
|
||||||
[text {:keys [message-id old-message-id content current-public-key user-statuses] :as message} style]
|
[text {:keys [chat-id message-id old-message-id content group-chat expanded? current-public-key user-statuses] :as message} style]
|
||||||
[react/view {:flex 1 :margin-vertical 5}
|
[react/view {:flex 1 :margin-vertical 5}
|
||||||
[react/touchable-highlight {:on-press (fn [arg]
|
[react/touchable-highlight {:on-press (fn [arg]
|
||||||
(when (= "right" (.-button (.-nativeEvent arg)))
|
(when (= "right" (.-button (.-nativeEvent arg)))
|
||||||
|
@ -108,15 +109,19 @@
|
||||||
{:text (i18n/label :t/message-reply)
|
{:text (i18n/label :t/message-reply)
|
||||||
:on-select #(when (message-sent? user-statuses current-public-key)
|
:on-select #(when (message-sent? user-statuses current-public-key)
|
||||||
(re-frame/dispatch [:chat.ui/reply-to-message message-id old-message-id]))}])))}
|
(re-frame/dispatch [:chat.ui/reply-to-message message-id old-message-id]))}])))}
|
||||||
[react/view {:style styles/message-container}
|
(let [collapsible? (and (:should-collapse? content) group-chat)
|
||||||
(when (:response-to content)
|
message-text (cond-> (:text content)
|
||||||
[quoted-message (:response-to content) false current-public-key])
|
(and collapsible? (not expanded?))
|
||||||
[react/text {:style (styles/message-text false)
|
(core-utils/truncate-str constants/chars-collapse-threshold))]
|
||||||
:selectable true
|
[react/view {:style styles/message-container}
|
||||||
:selection-color colors/blue-light}
|
(when (:response-to content)
|
||||||
(if-let [render-recipe (:render-recipe content)]
|
[quoted-message (:response-to content) false current-public-key])
|
||||||
(chat-utils/render-chunks render-recipe message)
|
[react/text {:style (styles/message-text collapsible? false)
|
||||||
(:text content))]]]])
|
:selectable true
|
||||||
|
:selection-color colors/blue-light}
|
||||||
|
message-text]
|
||||||
|
(when collapsible?
|
||||||
|
[message/expand-button expanded? chat-id message-id])])]])
|
||||||
|
|
||||||
(views/defview photo-placeholder []
|
(views/defview photo-placeholder []
|
||||||
[react/view {:style {:width 40
|
[react/view {:style {:width 40
|
||||||
|
|
Loading…
Reference in New Issue