From 5aa33fc9c0bf9dc813206aa16f7572f9f9e9106a Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Wed, 9 Sep 2020 14:18:23 +0300 Subject: [PATCH] [mentions] Fix mention appearance in reply and quoted message --- src/status_im/data_store/messages.cljs | 1 + .../ui/screens/chat/components/reply.cljs | 21 ++++++++++++++++--- .../ui/screens/chat/message/message.cljs | 11 ++++++---- status-go-version.json | 6 +++--- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index 5c2a222dfc..cecde4f7a6 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -27,6 +27,7 @@ :outgoingStatus :outgoing-status :audioDurationMs :audio-duration-ms}) + (update :quoted-message clojure.set/rename-keys {:parsedText :parsed-text}) (update :outgoing-status keyword) (update :command-parameters clojure.set/rename-keys {:transactionHash :transaction-hash :commandState :command-state}) diff --git a/src/status_im/ui/screens/chat/components/reply.cljs b/src/status_im/ui/screens/chat/components/reply.cljs index da484a21cc..579fa8dd32 100644 --- a/src/status_im/ui/screens/chat/components/reply.cljs +++ b/src/status_im/ui/screens/chat/components/reply.cljs @@ -8,7 +8,8 @@ [status-im.ethereum.stateofus :as stateofus] [status-im.ui.screens.chat.components.style :as styles] [re-frame.core :as re-frame] - [status-im.ui.components.react :as react])) + [status-im.ui.components.react :as react] + [clojure.string :as string])) (def ^:private reply-symbol "↪ ") @@ -25,10 +26,24 @@ (str reply-symbol (i18n/label :t/You))) (format-author (str reply-symbol username)))) +(defn get-quoted-text-with-mentions [parsed-text] + (string/join + (mapv (fn [{:keys [type literal children]}] + (cond + (= type "paragraph") + (get-quoted-text-with-mentions children) + + (= type "mention") + @(re-frame/subscribe [:contacts/contact-name-by-identity literal]) + + :else + literal)) + parsed-text))) + (defn reply-message [{:keys [from content]}] (let [contact-name @(re-frame/subscribe [:contacts/contact-name-by-identity from]) current-public-key @(re-frame/subscribe [:multiaccount/public-key]) - {:keys [image text]} content] + {:keys [image parsed-text]} content] [rn/view {:style (styles/reply-container false)} [rn/view {:style (styles/reply-content)} [quo/text {:weight :medium @@ -46,7 +61,7 @@ [quo/text {:size :small :number-of-lines 1 :style {:line-height 18}} - text])] + (get-quoted-text-with-mentions parsed-text)])] [rn/view [pressable/pressable {:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply]) :accessibility-label :cancel-message-reply} diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index 398630d835..15dd27c55f 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -16,7 +16,8 @@ [status-im.utils.security :as security] [status-im.ui.screens.chat.message.reactions :as reactions] [quo.core :as quo] - [reagent.core :as reagent]) + [reagent.core :as reagent] + [status-im.ui.screens.chat.components.reply :as components.reply]) (:require-macros [status-im.utils.views :refer [defview letsubs]])) (defview mention-element [from] @@ -33,7 +34,7 @@ (:rtl? content))} timestamp-str])) (defview quoted-message - [_ {:keys [from text image]} outgoing current-public-key public?] + [_ {:keys [from parsed-text image]} outgoing current-public-key public?] (letsubs [contact-name [:contacts/contact-name-by-identity from]] [react/view {:style (style/quoted-message-container outgoing)} [react/view {:style style/quoted-message-author-container} @@ -52,7 +53,7 @@ :source {:uri image}}] [react/text {:style (style/quoted-message-text outgoing) :number-of-lines 5} - text])])) + (components.reply/get-quoted-text-with-mentions parsed-text)])])) (defn render-inline [message-text outgoing content-type acc {:keys [type literal destination]}] (case type @@ -246,7 +247,9 @@ (on-long-press [{:on-press #(re-frame/dispatch [:chat.ui/reply-to-message message]) :label (i18n/label :t/message-reply)} - {:on-press #(react/copy-to-clipboard (get content :text)) + {:on-press #(react/copy-to-clipboard + (components.reply/get-quoted-text-with-mentions + (get content :parsed-text))) :label (i18n/label :t/sharing-copy-to-clipboard)}]))}) [react/view (style/message-view message) (let [response-to (:response-to content)] diff --git a/status-go-version.json b/status-go-version.json index 747cef9333..400f2e205d 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "0.60.0", - "commit-sha1": "3b748a2e467fe0850b2630947a9dadfe180f35fb", - "src-sha256": "1fvrh62480xfjcaagvwl7n7njhavb6plw48rv9w5vy9ykqj089bx" + "version": "v0.60.2", + "commit-sha1": "57728224d45ce3086e135988ae02e247abbc7b60", + "src-sha256": "1smgazlkgjxqq27ncgxagdi3523vcnmrca7lgj0lbxb4kbqgmmbl" }