[#12649] Mention preview is displayed as @0x... instead of user name/ENS on the home screen and in the Activity center
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
cd35af4e00
commit
0b2d0d45ed
|
@ -4,7 +4,8 @@
|
|||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.utils.fx :as fx]
|
||||
[taoensso.timbre :as log]))
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.types :as types]))
|
||||
|
||||
(defn rpc->type [{:keys [chat-type name] :as chat}]
|
||||
(cond
|
||||
|
@ -90,7 +91,8 @@
|
|||
:chat-type (.-chatType chat)
|
||||
:unviewed-messages-count (.-unviewedMessagesCount chat)
|
||||
:unviewed-mentions-count (.-unviewedMentionsCount chat)
|
||||
:last-message {:content {:text (.-text chat)}
|
||||
:last-message {:content {:text (.-text chat)
|
||||
:parsed-text (types/js->clj (.-parsedText chat))}
|
||||
:content-type (.-contentType chat)}
|
||||
:last-clock-value (.-lastClockValue chat)
|
||||
:profile-public-key (.-profile chat)}
|
||||
|
|
|
@ -160,7 +160,6 @@
|
|||
community-key]]]))
|
||||
|
||||
(defn render-featured-community [{:keys [name id]}]
|
||||
^{:key id}
|
||||
[react/touchable-highlight {:on-press #(>evt [:navigate-to :community {:community-id id}])
|
||||
:accessibility-label :chat-item}
|
||||
[react/view {:padding-right 8
|
||||
|
|
|
@ -61,7 +61,8 @@
|
|||
[react/view {:flex-direction :row :flex-wrap :wrap :justify-content :center
|
||||
:margin-top 10
|
||||
:margin-bottom 18}
|
||||
(for [community communities/featured]
|
||||
(for [{:keys [id] :as community} communities/featured]
|
||||
^{:key id}
|
||||
[communities.views/render-featured-community community])]])])
|
||||
|
||||
(defn welcome-blank-page []
|
||||
|
|
|
@ -19,6 +19,58 @@
|
|||
:accessibility-label :no-messages-text}
|
||||
(i18n/label label-key)])
|
||||
|
||||
(def max-subheader-length 100)
|
||||
|
||||
(defn truncate-literal [literal]
|
||||
(when literal
|
||||
(let [size (min max-subheader-length (.-length literal))]
|
||||
{:components (.substring literal 0 size)
|
||||
:length size})))
|
||||
|
||||
(defn add-parsed-to-subheader [acc {:keys [type destination literal children]}]
|
||||
(let [result (case type
|
||||
"paragraph"
|
||||
(reduce
|
||||
(fn [{:keys [_ length] :as acc-paragraph} parsed-child]
|
||||
(if (>= length max-subheader-length)
|
||||
(reduced acc-paragraph)
|
||||
(add-parsed-to-subheader acc-paragraph parsed-child)))
|
||||
{:components [react/text-class]
|
||||
:length 0}
|
||||
children)
|
||||
|
||||
"mention"
|
||||
{:components [react/text-class @(re-frame/subscribe [:contacts/contact-name-by-identity literal])]
|
||||
:length 4} ;; we can't predict name length so take the smallest possible
|
||||
|
||||
"status-tag"
|
||||
(truncate-literal (str "#" literal))
|
||||
|
||||
"link"
|
||||
(truncate-literal destination)
|
||||
|
||||
(truncate-literal literal))]
|
||||
{:components (conj (:components acc) (:components result))
|
||||
:length (+ (:length acc) (:length result))}))
|
||||
|
||||
(defn render-subheader
|
||||
"Render the preview of a last message to a maximum of max-subheader-length characters"
|
||||
[parsed-text]
|
||||
(println "PARSED" parsed-text)
|
||||
(let [result
|
||||
(reduce
|
||||
(fn [{:keys [_ length] :as acc-text} new-text-chunk]
|
||||
(if (>= length max-subheader-length)
|
||||
(reduced acc-text)
|
||||
(add-parsed-to-subheader acc-text new-text-chunk)))
|
||||
{:components [react/text-class {:style styles/last-message-text
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :tail
|
||||
:accessibility-label :chat-message-text}]
|
||||
:length 0}
|
||||
parsed-text)]
|
||||
(:components result)))
|
||||
|
||||
(defn message-content-text [{:keys [content content-type]} absolute]
|
||||
[react/view (when absolute {:position :absolute :left 72 :top 32 :right 80})
|
||||
(cond
|
||||
|
@ -27,11 +79,13 @@
|
|||
|
||||
(and (= constants/content-type-text content-type)
|
||||
(not (string/blank? (:text content))))
|
||||
(if (string/blank? (:parsed-text content))
|
||||
[react/text-class {:style styles/last-message-text
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :tail
|
||||
:accessibility-label :chat-message-text}
|
||||
(:text content)]
|
||||
[render-subheader (:parsed-text content)])
|
||||
|
||||
(= constants/content-type-sticker content-type)
|
||||
[preview-label :t/sticker]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.89.5",
|
||||
"commit-sha1": "c3ced098390f3d4e8d4850d9c0bf6e7dbd627c20",
|
||||
"src-sha256": "10bpf87sshji6azf9vpmx90vbgwf2c8agcrcvc7x5qrqkpnbmd9p"
|
||||
"version": "v0.89.6",
|
||||
"commit-sha1": "7701368b142ad073f76d678095114b1388cce4b3",
|
||||
"src-sha256": "0cgl5vhbn943sbzxzrnmpipxgyvlp4p3k96m5qp86cpw40rnhv9w"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue