Add username to quoted message

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-09-30 13:33:45 +02:00
parent c8b4fdfcd9
commit 42961f3a0e
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
5 changed files with 32 additions and 32 deletions

View File

@ -45,6 +45,7 @@
[status-im.wallet.core :as wallet] [status-im.wallet.core :as wallet]
[status-im.wallet.db :as wallet.db] [status-im.wallet.db :as wallet.db]
[status-im.signing.gas :as signing.gas] [status-im.signing.gas :as signing.gas]
[status-im.utils.gfycat.core :as gfycat]
status-im.ui.screens.hardwallet.connect.subs status-im.ui.screens.hardwallet.connect.subs
status-im.ui.screens.hardwallet.settings.subs status-im.ui.screens.hardwallet.settings.subs
status-im.ui.screens.hardwallet.pin.subs status-im.ui.screens.hardwallet.pin.subs
@ -1479,8 +1480,13 @@
(fn [[contacts current-multiaccount] [_ identity]] (fn [[contacts current-multiaccount] [_ identity]]
(let [me? (= (:public-key current-multiaccount) identity)] (let [me? (= (:public-key current-multiaccount) identity)]
(if me? (if me?
(:name current-multiaccount) {:username (:name current-multiaccount)
(:name (contacts identity)))))) :alias (gfycat/generate-gfy identity)}
(let [contact (or (contacts identity)
(contact.db/public-key->new-contact identity))]
{:username (:name contact)
:alias (or (:alias contact)
(gfycat/generate-gfy identity))})))))
(re-frame/reg-sub (re-frame/reg-sub
:contacts/all-contacts-not-in-current-chat :contacts/all-contacts-not-in-current-chat

View File

@ -154,20 +154,20 @@
[vector-icons/icon :main-icons/commands {:container-style style/input-commands-icon [vector-icons/icon :main-icons/commands {:container-style style/input-commands-icon
:color colors/gray}]]]))) :color colors/gray}]]])))
(defview reply-message [from message-text] (defview reply-message [from alias message-text]
(letsubs [username [:contacts/contact-name-by-identity from] (letsubs [{:keys [username]} [:contacts/contact-name-by-identity from]
current-public-key [:multiaccount/public-key]] current-public-key [:multiaccount/public-key]]
[react/scroll-view {:style style/reply-message-content} [react/scroll-view {:style style/reply-message-content}
(chat-utils/format-reply-author from username current-public-key style/reply-message-author) (chat-utils/format-reply-author from alias username current-public-key style/reply-message-author)
[react/text {:style (message-style/style-message-text false)} message-text]])) [react/text {:style (message-style/style-message-text false)} message-text]]))
(defview reply-message-view [] (defview reply-message-view []
(letsubs [{:keys [content from] :as message} [:chats/reply-message]] (letsubs [{:keys [content from alias] :as message} [:chats/reply-message]]
(when message (when message
[react/view {:style style/reply-message-container} [react/view {:style style/reply-message-container}
[react/view {:style style/reply-message} [react/view {:style style/reply-message}
[photos/member-photo from] [photos/member-photo from]
[reply-message from (:text content)]] [reply-message from alias (:text content)]]
[react/touchable-highlight [react/touchable-highlight
{:style style/cancel-reply-highlight {:style style/cancel-reply-highlight
:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply]) :on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply])

View File

@ -45,11 +45,11 @@
content content-type]]) content content-type]])
(defview quoted-message [{:keys [from text]} outgoing current-public-key] (defview quoted-message [{:keys [from text]} outgoing current-public-key]
(letsubs [username [:contacts/contact-name-by-identity from]] (letsubs [{:keys [username alias]} [:contacts/contact-name-by-identity from]]
[react/view {:style (style/quoted-message-container outgoing)} [react/view {:style (style/quoted-message-container outgoing)}
[react/view {:style style/quoted-message-author-container} [react/view {:style style/quoted-message-author-container}
[vector-icons/tiny-icon :tiny-icons/tiny-reply {:color (if outgoing colors/white-transparent colors/gray)}] [vector-icons/tiny-icon :tiny-icons/tiny-reply {:color (if outgoing colors/white-transparent colors/gray)}]
(chat.utils/format-reply-author from username current-public-key (partial style/quoted-message-author outgoing))] (chat.utils/format-reply-author from alias username current-public-key (partial style/quoted-message-author outgoing))]
[react/text {:style (style/quoted-message-text outgoing) [react/text {:style (style/quoted-message-text outgoing)
:number-of-lines 5} :number-of-lines 5}
@ -92,11 +92,11 @@
{:justify-timestamp? true}]) {:justify-timestamp? true}])
(defn emoji-message (defn emoji-message
[{:keys [content current-public-key] :as message}] [{:keys [content current-public-key alias] :as message}]
[message-view message [message-view message
[react/view {:style (style/style-message-text false)} [react/view {:style (style/style-message-text false)}
(when (:response-to content) (when (:response-to content)
[quoted-message (:response-to content) false current-public-key]) [quoted-message (:response-to content) alias false current-public-key])
[react/text {:style (style/emoji-message message)} [react/text {:style (style/emoji-message message)}
(:text content)]]]) (:text content)]]])
@ -197,8 +197,7 @@
[command-status content])))) [command-status content]))))
(defview message-author-name [alias name] (defview message-author-name [alias name]
(letsubs [username [:contacts/contact-name-by-identity alias]] (chat.utils/format-author alias style/message-author-name name))
(chat.utils/format-author alias style/message-author-name name)))
(defn message-body (defn message-body
[{:keys [last-in-group? [{:keys [last-in-group?

View File

@ -11,23 +11,18 @@
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.utils.http :as http])) [status-im.utils.http :as http]))
(defn format-author [from style name] (defn format-author [alias style name]
(cond (if (ens/is-valid-eth-name? name)
(ens/is-valid-eth-name? name)
[react/text {:style {:color colors/blue :font-size 13 :font-weight "500"}} [react/text {:style {:color colors/blue :font-size 13 :font-weight "500"}}
(str "@" (or (stateofus/username name) name))] (str "@" (or (stateofus/username name) name))]
name
[react/text {:style {:color colors/blue :font-size 13 :font-weight "500"}}
name]
:else
[react/text {:style {:color colors/gray :font-size 12 :font-weight "400"}} [react/text {:style {:color colors/gray :font-size 12 :font-weight "400"}}
from])) alias]))
(defn format-reply-author [from username current-public-key style] (defn format-reply-author [from alias username current-public-key style]
(or (and (= from current-public-key) (or (and (= from current-public-key)
[react/text {:style (style true)} [react/text {:style (style true)}
(i18n/label :t/You)]) (i18n/label :t/You)])
(format-author from style nil))) (format-author alias style username)))
(def ^:private styling->prop (def ^:private styling->prop
{:bold {:style {:font-weight "700"}} {:bold {:style {:font-weight "700"}}

View File

@ -64,7 +64,7 @@
:height 24}}]]])) :height 24}}]]]))
(views/defview message-author-name [{:keys [from]}] (views/defview message-author-name [{:keys [from]}]
(views/letsubs [incoming-name [:contacts/contact-name-by-identity from]] (views/letsubs [{:keys [username]} [:contacts/contact-name-by-identity from]]
[react/view {:flex-direction :row} [react/view {:flex-direction :row}
(when incoming-name (when incoming-name
[react/text {:style styles/author} incoming-name]) [react/text {:style styles/author} incoming-name])
@ -85,14 +85,14 @@
:style styles/photo-style}]]]]])) :style styles/photo-style}]]]]]))
(views/defview quoted-message [{:keys [from text]} outgoing current-public-key] (views/defview quoted-message [{:keys [from text]} outgoing current-public-key]
(views/letsubs [username [:contacts/contact-name-by-identity from]] (views/letsubs [{:keys [username alias]} [:contacts/contact-name-by-identity from]]
[react/view {:style styles/quoted-message-container} [react/view {:style styles/quoted-message-container}
[react/view {:style styles/quoted-message-author-container} [react/view {:style styles/quoted-message-author-container}
[vector-icons/tiny-icon :tiny-icons/tiny-reply {:style (styles/reply-icon outgoing) [vector-icons/tiny-icon :tiny-icons/tiny-reply {:style (styles/reply-icon outgoing)
:width 16 :width 16
:height 16 :height 16
:container-style (when outgoing {:opacity 0.4})}] :container-style (when outgoing {:opacity 0.4})}]
(chat-utils/format-reply-author from username current-public-key (partial message.style/quoted-message-author outgoing))] (chat-utils/format-reply-author from alias username current-public-key (partial message.style/quoted-message-author outgoing))]
[react/text {:style (message.style/quoted-message-text outgoing) [react/text {:style (message.style/quoted-message-text outgoing)
:number-of-lines 5} :number-of-lines 5}
(core-utils/truncate-str text constants/chars-collapse-threshold)]])) (core-utils/truncate-str text constants/chars-collapse-threshold)]]))
@ -101,7 +101,7 @@
(not (#{:not-sent :sending} outgoing-status))) (not (#{:not-sent :sending} outgoing-status)))
(views/defview message-without-timestamp (views/defview message-without-timestamp
[text {:keys [chat-id message-id content group-chat expanded? current-public-key outgoing-status] :as message} style] [text {:keys [chat-id message-id content group-chat alias expanded? current-public-key outgoing-status] :as message} style]
[react/view {:flex 1 :margin-vertical 5} [react/view {:flex 1 :margin-vertical 5}
[react/touchable-highlight {:on-press (fn [arg] [react/touchable-highlight {:on-press (fn [arg]
(when (= "right" (.-button (.-nativeEvent arg))) (when (= "right" (.-button (.-nativeEvent arg)))
@ -270,11 +270,11 @@
[react/view {:style (styles/send-icon inactive?)} [react/view {:style (styles/send-icon inactive?)}
[vector-icons/icon :main-icons/arrow-left {:style (styles/send-icon-arrow inactive?)}]]]))) [vector-icons/icon :main-icons/arrow-left {:style (styles/send-icon-arrow inactive?)}]]])))
(views/defview reply-message [from message-text] (views/defview reply-message [from alias message-text]
(views/letsubs [username [:contacts/contact-name-by-identity from] (views/letsubs [{:keys [username]} [:contacts/contact-name-by-identity from]
current-public-key [:multiaccount/public-key]] current-public-key [:multiaccount/public-key]]
[react/view {:style styles/reply-content-container} [react/view {:style styles/reply-content-container}
(chat-utils/format-reply-author from username current-public-key styles/reply-content-author) (chat-utils/format-reply-author from alias username current-public-key styles/reply-content-author)
[react/text {:style styles/reply-content-message} message-text]])) [react/text {:style styles/reply-content-message} message-text]]))
(views/defview reply-member-photo [from] (views/defview reply-member-photo [from]
@ -285,12 +285,12 @@
:style styles/reply-photo-style}])) :style styles/reply-photo-style}]))
(views/defview reply-message-view [] (views/defview reply-message-view []
(views/letsubs [{:keys [content from] :as message} [:chats/reply-message]] (views/letsubs [{:keys [alias content from] :as message} [:chats/reply-message]]
(when message (when message
[react/view {:style styles/reply-wrapper} [react/view {:style styles/reply-wrapper}
[react/view {:style styles/reply-container} [react/view {:style styles/reply-container}
[reply-member-photo from] [reply-member-photo from]
[reply-message from (:text content)]] [reply-message from alias (:text content)]]
[react/touchable-highlight [react/touchable-highlight
{:style styles/reply-close-highlight {:style styles/reply-close-highlight
:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply]) :on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply])