[#6232] Link is not visible when sending it as my own message

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-10-10 10:25:48 +02:00
parent 2cab2bdc05
commit b63602e1ff
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4

View File

@ -104,14 +104,15 @@
(fn [text-seq]
(map (fn [text] {:text text :url? false}) text-seq))))
(defn- autolink [string event-on-press]
(defn- autolink [string event-on-press outgoing]
(->> (parse-url string)
(map-indexed (fn [idx {:keys [text url?]}]
(if url?
(let [[url _ _ _ text] (re-matches #"(?i)^((\w+://)?(www\d{0,3}[.])?)?(.*)$" text)]
[react/text
{:key idx
:style {:color colors/blue}
:style {:color (if outgoing colors/white colors/blue)
:text-decoration-line :underline}
:on-press #(re-frame/dispatch [event-on-press url])}
url])
text)))
@ -127,7 +128,7 @@
replacements))
;; todo rewrite this, naive implementation
(defn- parse-text [string event-on-press]
(defn- parse-text [string event-on-press outgoing]
(parse-str-regx string
regx-styled
(fn [text-seq]
@ -142,7 +143,7 @@
(map-indexed (fn [idx string]
(apply react/text
{:key (str idx "_" string)}
(autolink string event-on-press)))
(autolink string event-on-press outgoing)))
text-seq))))
; We can't use CSS as nested Text element don't accept margins nor padding
@ -180,7 +181,7 @@
(defn text-message
[{:keys [content timestamp-str group-chat outgoing current-public-key] :as message}]
[message-view message
(let [parsed-text (cached-parse-text (:text content) :browser.ui/message-link-pressed)
(let [parsed-text (cached-parse-text (:text content) :browser.ui/message-link-pressed outgoing)
ref (reagent/atom nil)
collapsible? (should-collapse? (:text content) group-chat)
collapsed? (reagent/atom collapsible?)