[#15655] Resolve messages with markdown on Jump To screen
This commit is contained in:
parent
f9eae4ef82
commit
1b0374a156
|
@ -1,29 +1,8 @@
|
|||
(ns status-im2.contexts.chat.messages.pin.banner.view
|
||||
(:require [quo2.core :as quo]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn resolve-message
|
||||
[parsed-text]
|
||||
(reduce
|
||||
(fn [acc {:keys [type literal destination] :as some-text}]
|
||||
(str acc
|
||||
(case type
|
||||
"paragraph"
|
||||
(resolve-message (:children some-text))
|
||||
|
||||
"mention"
|
||||
(rf/sub [:messages/resolve-mention literal])
|
||||
|
||||
"status-tag"
|
||||
(str "#" literal)
|
||||
|
||||
"link"
|
||||
destination
|
||||
|
||||
literal)))
|
||||
""
|
||||
parsed-text))
|
||||
[utils.re-frame :as rf]
|
||||
[status-im2.utils.message-resolver :as resolver]))
|
||||
|
||||
(defn banner
|
||||
[chat-id]
|
||||
|
@ -35,7 +14,7 @@
|
|||
latest-pin-text
|
||||
(cond deleted? (i18n/label :t/message-deleted-for-everyone)
|
||||
deleted-for-me? (i18n/label :t/message-deleted-for-you)
|
||||
:else (resolve-message latest-pin-text))]
|
||||
:else (resolver/resolve-message latest-pin-text))]
|
||||
[quo/banner
|
||||
{:latest-pin-text latest-pin-text
|
||||
:pins-count pins-count
|
||||
|
|
|
@ -7,10 +7,14 @@
|
|||
[react-native.fast-image :as fast-image]
|
||||
[status-im2.constants :as constants]
|
||||
[status-im2.contexts.shell.cards.style :as style]
|
||||
[status-im2.contexts.shell.constants :as shell.constants]))
|
||||
[status-im2.contexts.shell.constants :as shell.constants]
|
||||
[status-im2.utils.message-resolver :as resolver]))
|
||||
|
||||
(defn content-container
|
||||
[type {:keys [content-type data new-notifications? color-50 community-info community-channel]}]
|
||||
[type
|
||||
{:keys [content-type data new-notifications? color-50 community-info
|
||||
community-channel]
|
||||
{:keys [text parsed-text source]} :data}]
|
||||
[rn/view {:style (style/content-container new-notifications?)}
|
||||
(case type
|
||||
shell.constants/community-card
|
||||
|
@ -52,7 +56,9 @@
|
|||
:number-of-lines 1
|
||||
:ellipsize-mode :tail
|
||||
:style style/last-message-text}
|
||||
data]
|
||||
(if parsed-text
|
||||
(resolver/resolve-message parsed-text)
|
||||
text)]
|
||||
|
||||
constants/content-type-image
|
||||
[quo/preview-list
|
||||
|
@ -63,13 +69,12 @@
|
|||
|
||||
constants/content-type-sticker
|
||||
[fast-image/fast-image
|
||||
{:source (:source data)
|
||||
{:source source
|
||||
:style style/sticker}]
|
||||
|
||||
|
||||
constants/content-type-gif
|
||||
[fast-image/fast-image
|
||||
{:source (:source data)
|
||||
{:source source
|
||||
:style style/gif}]
|
||||
|
||||
constants/content-type-audio
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
(constants/content-type-text
|
||||
constants/content-type-emoji)
|
||||
{:content-type constants/content-type-text
|
||||
:data (get-in last-message [:content :text])}
|
||||
:data (get last-message :content)}
|
||||
|
||||
;; Currently mock image is used as placeholder,
|
||||
;; as last-message don't have image
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
(ns status-im2.utils.message-resolver
|
||||
(:require [utils.re-frame :as rf]))
|
||||
|
||||
(defn resolve-message
|
||||
[parsed-text]
|
||||
(reduce
|
||||
(fn [acc {:keys [type literal destination] :as some-text}]
|
||||
(str acc
|
||||
(case type
|
||||
"paragraph"
|
||||
(resolve-message (:children some-text))
|
||||
|
||||
"mention"
|
||||
(rf/sub [:messages/resolve-mention literal])
|
||||
|
||||
"status-tag"
|
||||
(str "#" literal)
|
||||
|
||||
"link"
|
||||
destination
|
||||
|
||||
literal)))
|
||||
""
|
||||
parsed-text))
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im2.contexts.chat.messages.pin.banner.view-test
|
||||
(:require [status-im2.contexts.chat.messages.pin.banner.view :as view]
|
||||
(ns status-im2.utils.message-resolver-test
|
||||
(:require [status-im2.utils.message-resolver :as resolver]
|
||||
[cljs.test :as t]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -29,6 +29,6 @@
|
|||
(t/deftest test-resolve-message
|
||||
(with-redefs [rf/sub sub]
|
||||
(t/testing ""
|
||||
(let [text (view/resolve-message parsed-text)]
|
||||
(let [text (resolver/resolve-message parsed-text)]
|
||||
(t/is (= text
|
||||
"foobar i just mention you here to debug this issue https://foo.bar , no worries"))))))
|
Loading…
Reference in New Issue