[#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
|
(ns status-im2.contexts.chat.messages.pin.banner.view
|
||||||
(:require [quo2.core :as quo]
|
(:require [quo2.core :as quo]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]
|
||||||
|
[status-im2.utils.message-resolver :as resolver]))
|
||||||
(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))
|
|
||||||
|
|
||||||
(defn banner
|
(defn banner
|
||||||
[chat-id]
|
[chat-id]
|
||||||
|
@ -35,7 +14,7 @@
|
||||||
latest-pin-text
|
latest-pin-text
|
||||||
(cond deleted? (i18n/label :t/message-deleted-for-everyone)
|
(cond deleted? (i18n/label :t/message-deleted-for-everyone)
|
||||||
deleted-for-me? (i18n/label :t/message-deleted-for-you)
|
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
|
[quo/banner
|
||||||
{:latest-pin-text latest-pin-text
|
{:latest-pin-text latest-pin-text
|
||||||
:pins-count pins-count
|
:pins-count pins-count
|
||||||
|
|
|
@ -7,10 +7,14 @@
|
||||||
[react-native.fast-image :as fast-image]
|
[react-native.fast-image :as fast-image]
|
||||||
[status-im2.constants :as constants]
|
[status-im2.constants :as constants]
|
||||||
[status-im2.contexts.shell.cards.style :as style]
|
[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
|
(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?)}
|
[rn/view {:style (style/content-container new-notifications?)}
|
||||||
(case type
|
(case type
|
||||||
shell.constants/community-card
|
shell.constants/community-card
|
||||||
|
@ -52,7 +56,9 @@
|
||||||
:number-of-lines 1
|
:number-of-lines 1
|
||||||
:ellipsize-mode :tail
|
:ellipsize-mode :tail
|
||||||
:style style/last-message-text}
|
:style style/last-message-text}
|
||||||
data]
|
(if parsed-text
|
||||||
|
(resolver/resolve-message parsed-text)
|
||||||
|
text)]
|
||||||
|
|
||||||
constants/content-type-image
|
constants/content-type-image
|
||||||
[quo/preview-list
|
[quo/preview-list
|
||||||
|
@ -63,13 +69,12 @@
|
||||||
|
|
||||||
constants/content-type-sticker
|
constants/content-type-sticker
|
||||||
[fast-image/fast-image
|
[fast-image/fast-image
|
||||||
{:source (:source data)
|
{:source source
|
||||||
:style style/sticker}]
|
:style style/sticker}]
|
||||||
|
|
||||||
|
|
||||||
constants/content-type-gif
|
constants/content-type-gif
|
||||||
[fast-image/fast-image
|
[fast-image/fast-image
|
||||||
{:source (:source data)
|
{:source source
|
||||||
:style style/gif}]
|
:style style/gif}]
|
||||||
|
|
||||||
constants/content-type-audio
|
constants/content-type-audio
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
(constants/content-type-text
|
(constants/content-type-text
|
||||||
constants/content-type-emoji)
|
constants/content-type-emoji)
|
||||||
{:content-type constants/content-type-text
|
{: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,
|
;; Currently mock image is used as placeholder,
|
||||||
;; as last-message don't have image
|
;; 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
|
(ns status-im2.utils.message-resolver-test
|
||||||
(:require [status-im2.contexts.chat.messages.pin.banner.view :as view]
|
(:require [status-im2.utils.message-resolver :as resolver]
|
||||||
[cljs.test :as t]
|
[cljs.test :as t]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
@ -29,6 +29,6 @@
|
||||||
(t/deftest test-resolve-message
|
(t/deftest test-resolve-message
|
||||||
(with-redefs [rf/sub sub]
|
(with-redefs [rf/sub sub]
|
||||||
(t/testing ""
|
(t/testing ""
|
||||||
(let [text (view/resolve-message parsed-text)]
|
(let [text (resolver/resolve-message parsed-text)]
|
||||||
(t/is (= text
|
(t/is (= text
|
||||||
"foobar i just mention you here to debug this issue https://foo.bar , no worries"))))))
|
"foobar i just mention you here to debug this issue https://foo.bar , no worries"))))))
|
Loading…
Reference in New Issue