Skip to content

Commit

Permalink
Add username to quoted message
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed Oct 1, 2019
1 parent c8b4fdf commit 0769c35
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
10 changes: 8 additions & 2 deletions src/status_im/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
[status-im.wallet.core :as wallet]
[status-im.wallet.db :as wallet.db]
[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.settings.subs
status-im.ui.screens.hardwallet.pin.subs
Expand Down Expand Up @@ -1479,8 +1480,13 @@
(fn [[contacts current-multiaccount] [_ identity]]
(let [me? (= (:public-key current-multiaccount) identity)]
(if me?
(:name current-multiaccount)
(:name (contacts identity))))))
{:username (:name current-multiaccount)
: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
:contacts/all-contacts-not-in-current-chat
Expand Down
10 changes: 5 additions & 5 deletions src/status_im/ui/screens/chat/input/input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,20 @@
[vector-icons/icon :main-icons/commands {:container-style style/input-commands-icon
:color colors/gray}]]])))

(defview reply-message [from message-text]
(letsubs [username [:contacts/contact-name-by-identity from]
(defview reply-message [from alias message-text]
(letsubs [{:keys [username]} [:contacts/contact-name-by-identity from]
current-public-key [:multiaccount/public-key]]
[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]]))

(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
[react/view {:style style/reply-message-container}
[react/view {:style style/reply-message}
[photos/member-photo from]
[reply-message from (:text content)]]
[reply-message from alias (:text content)]]
[react/touchable-highlight
{:style style/cancel-reply-highlight
:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply])
Expand Down
11 changes: 5 additions & 6 deletions src/status_im/ui/screens/chat/message/message.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
content content-type]])

(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-author-container}
[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)
:number-of-lines 5}
Expand Down Expand Up @@ -92,11 +92,11 @@
{:justify-timestamp? true}])

(defn emoji-message
[{:keys [content current-public-key] :as message}]
[{:keys [content current-public-key alias] :as message}]
[message-view message
[react/view {:style (style/style-message-text false)}
(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)}
(:text content)]]])

Expand Down Expand Up @@ -197,8 +197,7 @@
[command-status content]))))

(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
[{:keys [last-in-group?
Expand Down
15 changes: 5 additions & 10 deletions src/status_im/ui/screens/chat/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@
[status-im.ui.components.colors :as colors]
[status-im.utils.http :as http]))

(defn format-author [from style name]
(cond
(ens/is-valid-eth-name? name)
(defn format-author [alias style name]
(if (ens/is-valid-eth-name? name)
[react/text {:style {:color colors/blue :font-size 13 :font-weight "500"}}
(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"}}
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)
[react/text {:style (style true)}
(i18n/label :t/You)])
(format-author from style nil)))
(format-author alias style username)))

(def ^:private styling->prop
{:bold {:style {:font-weight "700"}}
Expand Down
18 changes: 9 additions & 9 deletions src/status_im/ui/screens/desktop/main/chat/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
:height 24}}]]]))

(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}
(when incoming-name
[react/text {:style styles/author} incoming-name])
Expand All @@ -85,14 +85,14 @@
:style styles/photo-style}]]]]]))

(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-author-container}
[vector-icons/tiny-icon :tiny-icons/tiny-reply {:style (styles/reply-icon outgoing)
:width 16
:height 16
: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)
:number-of-lines 5}
(core-utils/truncate-str text constants/chars-collapse-threshold)]]))
Expand All @@ -101,7 +101,7 @@
(not (#{:not-sent :sending} outgoing-status)))

(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/touchable-highlight {:on-press (fn [arg]
(when (= "right" (.-button (.-nativeEvent arg)))
Expand Down Expand Up @@ -270,11 +270,11 @@
[react/view {:style (styles/send-icon inactive?)}
[vector-icons/icon :main-icons/arrow-left {:style (styles/send-icon-arrow inactive?)}]]])))

(views/defview reply-message [from message-text]
(views/letsubs [username [:contacts/contact-name-by-identity from]
(views/defview reply-message [from alias message-text]
(views/letsubs [{:keys [username]} [:contacts/contact-name-by-identity from]
current-public-key [:multiaccount/public-key]]
[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]]))

(views/defview reply-member-photo [from]
Expand All @@ -285,12 +285,12 @@
:style styles/reply-photo-style}]))

(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
[react/view {:style styles/reply-wrapper}
[react/view {:style styles/reply-container}
[reply-member-photo from]
[reply-message from (:text content)]]
[reply-message from alias (:text content)]]
[react/touchable-highlight
{:style styles/reply-close-highlight
:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply])
Expand Down

0 comments on commit 0769c35

Please sign in to comment.