diff --git a/src/status_im2/contexts/chat/messages/pin/banner/view.cljs b/src/status_im2/contexts/chat/messages/pin/banner/view.cljs index 93c8d4a6de..88b5926036 100644 --- a/src/status_im2/contexts/chat/messages/pin/banner/view.cljs +++ b/src/status_im2/contexts/chat/messages/pin/banner/view.cljs @@ -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 diff --git a/src/status_im2/contexts/shell/cards/view.cljs b/src/status_im2/contexts/shell/cards/view.cljs index c336f6e339..d7b18a6c5e 100644 --- a/src/status_im2/contexts/shell/cards/view.cljs +++ b/src/status_im2/contexts/shell/cards/view.cljs @@ -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 diff --git a/src/status_im2/subs/shell.cljs b/src/status_im2/subs/shell.cljs index 9e78c7011a..52b9b7e41b 100644 --- a/src/status_im2/subs/shell.cljs +++ b/src/status_im2/subs/shell.cljs @@ -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 diff --git a/src/status_im2/utils/message_resolver.cljs b/src/status_im2/utils/message_resolver.cljs new file mode 100644 index 0000000000..d450b8cc35 --- /dev/null +++ b/src/status_im2/utils/message_resolver.cljs @@ -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)) diff --git a/src/status_im2/contexts/chat/messages/pin/banner/view_test.cljs b/src/status_im2/utils/message_resolver_test.cljs similarity index 80% rename from src/status_im2/contexts/chat/messages/pin/banner/view_test.cljs rename to src/status_im2/utils/message_resolver_test.cljs index 6694bd4812..bc510dcfbf 100644 --- a/src/status_im2/contexts/chat/messages/pin/banner/view_test.cljs +++ b/src/status_im2/utils/message_resolver_test.cljs @@ -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"))))))