[#8854] Finish "Show my ENS name in chat" setting in user profile
This commit is contained in:
parent
ad80d4b0fd
commit
ec04709495
|
@ -1,6 +1,6 @@
|
||||||
(ns status-im.group-chats.db
|
(ns status-im.group-chats.db
|
||||||
(:require [status-im.chat.models :as models.chat]
|
(:require [status-im.chat.models :as models.chat]
|
||||||
[status-im.utils.gfycat.core :as gfycat]))
|
[status-im.multiaccounts.core :as multiaccounts]))
|
||||||
|
|
||||||
(defn unwrap-events
|
(defn unwrap-events
|
||||||
"Flatten all events, denormalizing from field"
|
"Flatten all events, denormalizing from field"
|
||||||
|
@ -36,15 +36,12 @@
|
||||||
(invited? my-public-key chat)
|
(invited? my-public-key chat)
|
||||||
(not (joined? my-public-key chat)))
|
(not (joined? my-public-key chat)))
|
||||||
(let [inviter-pk (get-inviter-pk my-public-key chat)]
|
(let [inviter-pk (get-inviter-pk my-public-key chat)]
|
||||||
(get-in contacts [inviter-pk :name]
|
(multiaccounts/displayed-name (or (get contacts inviter-pk) {:public-key inviter-pk})))))
|
||||||
(gfycat/generate-gfy inviter-pk)))))
|
|
||||||
|
|
||||||
(defn get-inviter-name
|
(defn get-inviter-name
|
||||||
"when the chat is a private group chat in which the user has been
|
"when the chat is a private group chat in which the user has been
|
||||||
invited and didn't accept the invitation yet, return inviter-name"
|
invited and didn't accept the invitation yet, return inviter-name"
|
||||||
[contacts chat my-public-key]
|
[contacts chat my-public-key]
|
||||||
(when (and (models.chat/group-chat? chat)
|
(when (models.chat/group-chat? chat)
|
||||||
(joined? my-public-key chat))
|
|
||||||
(let [inviter-pk (get-inviter-pk my-public-key chat)]
|
(let [inviter-pk (get-inviter-pk my-public-key chat)]
|
||||||
(get-in contacts [inviter-pk :name]
|
(multiaccounts/displayed-name (or (get contacts inviter-pk) {:public-key inviter-pk})))))
|
||||||
(gfycat/generate-gfy inviter-pk)))))
|
|
||||||
|
|
|
@ -15,20 +15,13 @@
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.utils.utils :as utils]))
|
[status-im.utils.utils :as utils]))
|
||||||
|
|
||||||
; Whether we should be strict about verifying ens, currently disabled as
|
|
||||||
; status-go can't be upgrade because of geth 1.9 incompatibility
|
|
||||||
(def only-verified-ens false)
|
|
||||||
(defn displayed-name
|
(defn displayed-name
|
||||||
"Use preferred name, name or alias in that order"
|
"Use preferred name, name or alias in that order"
|
||||||
[{:keys [name preferred-name alias public-key ens-verified]}]
|
[{:keys [name preferred-name alias public-key ens-verified]}]
|
||||||
(let [ens-name (or preferred-name
|
(let [ens-name (or preferred-name
|
||||||
name)]
|
name)]
|
||||||
;; Preferred name is our own
|
;; Preferred name is our own otherwise we make sure it's verified
|
||||||
;; otherwise we make sure is verified
|
(if (or preferred-name (and ens-verified name))
|
||||||
(if (or preferred-name
|
|
||||||
(and only-verified-ens
|
|
||||||
ens-verified
|
|
||||||
name))
|
|
||||||
(let [username (stateofus/username ens-name)]
|
(let [username (stateofus/username ens-name)]
|
||||||
(str "@" (or username ens-name)))
|
(str "@" (or username ens-name)))
|
||||||
(or alias (gfycat/generate-gfy public-key)))))
|
(or alias (gfycat/generate-gfy public-key)))))
|
||||||
|
|
|
@ -1657,7 +1657,8 @@
|
||||||
:<- [:contacts/contacts]
|
:<- [:contacts/contacts]
|
||||||
:<- [:multiaccount]
|
:<- [:multiaccount]
|
||||||
(fn [[{:keys [contacts admins]} all-contacts current-multiaccount]]
|
(fn [[{:keys [contacts admins]} all-contacts current-multiaccount]]
|
||||||
(contact.db/get-all-contacts-in-group-chat contacts admins all-contacts current-multiaccount)))
|
(map #(assoc % :name (multiaccounts/displayed-name %))
|
||||||
|
(contact.db/get-all-contacts-in-group-chat contacts admins all-contacts current-multiaccount))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:contacts/contacts-by-chat
|
:contacts/contacts-by-chat
|
||||||
|
|
|
@ -192,7 +192,7 @@
|
||||||
|
|
||||||
(defview message-author-name [from alias]
|
(defview message-author-name [from alias]
|
||||||
(letsubs [{:keys [ens-name]} [:contacts/contact-name-by-identity from]]
|
(letsubs [{:keys [ens-name]} [:contacts/contact-name-by-identity from]]
|
||||||
(chat.utils/format-author alias style/message-author-name ens-name)))
|
(chat.utils/format-author alias style/message-author-name-container ens-name)))
|
||||||
|
|
||||||
(defn message-body
|
(defn message-body
|
||||||
[{:keys [alias
|
[{:keys [alias
|
||||||
|
|
|
@ -180,6 +180,13 @@
|
||||||
:margin-right 12
|
:margin-right 12
|
||||||
:text-align-vertical :center})
|
:text-align-vertical :center})
|
||||||
|
|
||||||
|
(def message-author-name-container
|
||||||
|
{:padding-top 6
|
||||||
|
:padding-left 12
|
||||||
|
:padding-right 16
|
||||||
|
:margin-right 12
|
||||||
|
:text-align-vertical :center})
|
||||||
|
|
||||||
(defn quoted-message-container [outgoing]
|
(defn quoted-message-container [outgoing]
|
||||||
{:margin-bottom 6
|
{:margin-bottom 6
|
||||||
:padding-bottom 6
|
:padding-bottom 6
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
[status-im.ui.components.toolbar.view :as toolbar]
|
||||||
[status-im.ui.screens.chat.message.message :as message]
|
[status-im.ui.screens.chat.message.message :as message]
|
||||||
[status-im.ui.screens.profile.components.views :as profile.components]
|
[status-im.ui.screens.profile.components.views :as profile.components]
|
||||||
[status-im.utils.navigation :as navigation])
|
[status-im.utils.navigation :as navigation]
|
||||||
|
[status-im.ui.components.list-item.views :as list-item]
|
||||||
|
[status-im.ui.screens.chat.photos :as photos]
|
||||||
|
[status-im.multiaccounts.core :as multiaccounts])
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
(defn- button
|
(defn- button
|
||||||
|
@ -582,14 +585,15 @@
|
||||||
[button {:on-press #(re-frame/dispatch [::ens/get-started-pressed])
|
[button {:on-press #(re-frame/dispatch [::ens/get-started-pressed])
|
||||||
:label (i18n/label :t/get-started)}]]])
|
:label (i18n/label :t/get-started)}]]])
|
||||||
|
|
||||||
(defn- name-item [{:keys [name action hide-chevron?]}]
|
(defn- name-item [{:keys [name action]}]
|
||||||
(let [stateofus-username (stateofus/username name)
|
(let [stateofus-username (stateofus/username name)
|
||||||
s (or stateofus-username name)]
|
s (or stateofus-username name)]
|
||||||
[list/big-list-item {:text s
|
[list-item/list-item
|
||||||
:subtext (when stateofus-username stateofus/domain)
|
{:title s
|
||||||
:action-fn action
|
:subtitle (when stateofus-username stateofus/domain)
|
||||||
:icon :main-icons/username
|
:on-press action
|
||||||
:hide-chevron? hide-chevron?}]))
|
:icon :main-icons/username
|
||||||
|
:accessories [:chevron]}]))
|
||||||
|
|
||||||
(defn- name-list [names preferred-name]
|
(defn- name-list [names preferred-name]
|
||||||
[react/view {:style {:flex 1 :margin-top 16}}
|
[react/view {:style {:flex 1 :margin-top 16}}
|
||||||
|
@ -612,13 +616,15 @@
|
||||||
[name-item {:name name :hide-chevron? true :action action}]]
|
[name-item {:name name :hide-chevron? true :action action}]]
|
||||||
[radio/radio (= name preferred-name)]]]))]]]])
|
[radio/radio (= name preferred-name)]]]))]]]])
|
||||||
|
|
||||||
(defn- registered [names {:keys [preferred-name address public-key name]} show?]
|
(defn- registered [names {:keys [preferred-name public-key name] :as account} show?]
|
||||||
[react/view {:style {:flex 1}}
|
[react/view {:style {:flex 1}}
|
||||||
[react/scroll-view
|
[react/scroll-view
|
||||||
[react/view {:style {:margin-top 8}}
|
[react/view {:style {:margin-top 8}}
|
||||||
[list/big-list-item {:text (i18n/label :t/ens-add-username)
|
[list-item/list-item
|
||||||
:action-fn #(re-frame/dispatch [::ens/add-username-pressed])
|
{:title (i18n/label :t/ens-add-username)
|
||||||
:icon :main-icons/add}]]
|
:theme :action
|
||||||
|
:on-press #(re-frame/dispatch [::ens/add-username-pressed])
|
||||||
|
:icon :main-icons/add}]]
|
||||||
[react/view {:style {:margin-top 22 :margin-bottom 8}}
|
[react/view {:style {:margin-top 22 :margin-bottom 8}}
|
||||||
[react/text {:style {:color colors/gray :margin-horizontal 16}}
|
[react/text {:style {:color colors/gray :margin-horizontal 16}}
|
||||||
(i18n/label :t/ens-your-usernames)]
|
(i18n/label :t/ens-your-usernames)]
|
||||||
|
@ -645,26 +651,27 @@
|
||||||
{:label-kw :ens-show-username
|
{:label-kw :ens-show-username
|
||||||
:action-fn #(re-frame/dispatch [::ens/switch-show-username])
|
:action-fn #(re-frame/dispatch [::ens/switch-show-username])
|
||||||
:value show?}]]
|
:value show?}]]
|
||||||
(let [message (merge {:from public-key
|
(let [message (merge {:content {:text (i18n/label :t/ens-test-message)}
|
||||||
:last-in-group? true
|
|
||||||
:display-username? true
|
|
||||||
:display-photo? true
|
|
||||||
:alias name
|
|
||||||
:content {:text (i18n/label :t/ens-test-message)
|
|
||||||
:name (when show? preferred-name)}
|
|
||||||
:content-type "text/plain"
|
:content-type "text/plain"
|
||||||
:timestamp-str "9:41 AM"}
|
:timestamp-str "9:41 AM"})]
|
||||||
(when show?
|
[react/view
|
||||||
{:name preferred-name}))]
|
[react/view {:padding-left 60}
|
||||||
[message/message-body message
|
(if show?
|
||||||
[message/text-message message]])]])
|
^{:key "ens-name"}
|
||||||
|
[message/message-author-name public-key]
|
||||||
|
^{:key "generated"}
|
||||||
|
[message/message-author-name nil name])]
|
||||||
|
[react/view {:flex-direction :row}
|
||||||
|
[react/view {:padding-left 16 :padding-right 8 :padding-top 4}
|
||||||
|
[photos/photo (multiaccounts/displayed-photo account) {:size 36}]]
|
||||||
|
[message/text-message message]]])]])
|
||||||
|
|
||||||
(views/defview main []
|
(views/defview main []
|
||||||
(views/letsubs [{:keys [names multiaccount preferred-name show?]} [:ens.main/screen]]
|
(views/letsubs [{:keys [names multiaccount show?]} [:ens.main/screen]]
|
||||||
[react/keyboard-avoiding-view {:style {:flex 1}}
|
[react/keyboard-avoiding-view {:style {:flex 1}}
|
||||||
[status-bar/status-bar {:type :main}]
|
[status-bar/status-bar {:type :main}]
|
||||||
[toolbar/simple-toolbar
|
[toolbar/simple-toolbar
|
||||||
(i18n/label :t/ens-usernames)]
|
(i18n/label :t/ens-usernames)]
|
||||||
(if (seq names)
|
(if (seq names)
|
||||||
[registered names multiaccount show?]
|
[registered names multiaccount show?]
|
||||||
[welcome])]))
|
[welcome])]))
|
|
@ -44,6 +44,13 @@
|
||||||
:number-of-lines 1}
|
:number-of-lines 1}
|
||||||
generated-name])]))
|
generated-name])]))
|
||||||
|
|
||||||
|
(defn- group-name [name]
|
||||||
|
[react/view styles/profile-header-name-container
|
||||||
|
[react/text {:style styles/profile-name-text
|
||||||
|
:number-of-lines 2
|
||||||
|
:ellipsize-mode :tail}
|
||||||
|
name]])
|
||||||
|
|
||||||
(defn- profile-header-display [{:keys [name public-key] :as contact}
|
(defn- profile-header-display [{:keys [name public-key] :as contact}
|
||||||
allow-icon-change? include-remove-action?]
|
allow-icon-change? include-remove-action?]
|
||||||
[react/view (merge styles/profile-header-display {:padding-horizontal 16})
|
[react/view (merge styles/profile-header-display {:padding-horizontal 16})
|
||||||
|
@ -85,6 +92,11 @@
|
||||||
:edit? false}])
|
:edit? false}])
|
||||||
[names contact]])
|
[names contact]])
|
||||||
|
|
||||||
|
(defn group-header-display [{:keys [chat-name color]}]
|
||||||
|
[react/view (merge styles/profile-header-display {:padding-horizontal 16})
|
||||||
|
[chat-icon.screen/profile-icon-view nil chat-name color nil 64 nil]
|
||||||
|
[group-name chat-name]])
|
||||||
|
|
||||||
(defn profile-header
|
(defn profile-header
|
||||||
[{:keys [contact allow-icon-change? include-remove-action?]}]
|
[{:keys [contact allow-icon-change? include-remove-action?]}]
|
||||||
[profile-header-display contact allow-icon-change? include-remove-action?])
|
[profile-header-display contact allow-icon-change? include-remove-action?])
|
||||||
|
|
|
@ -54,9 +54,9 @@
|
||||||
; :content-height 150}
|
; :content-height 150}
|
||||||
; contact])
|
; contact])
|
||||||
|
|
||||||
(defn render-detail [{:keys [name public-key] :as detail}]
|
(defn render-detail [{:keys [alias public-key] :as detail}]
|
||||||
[list-item/list-item
|
[list-item/list-item
|
||||||
{:title name
|
{:title alias
|
||||||
:subtitle (utils/get-shortened-address public-key)
|
:subtitle (utils/get-shortened-address public-key)
|
||||||
:icon [chat-icon/contact-icon-contacts-tab detail]
|
:icon [chat-icon/contact-icon-contacts-tab detail]
|
||||||
:accessibility-label :profile-public-key
|
:accessibility-label :profile-public-key
|
||||||
|
@ -118,10 +118,12 @@
|
||||||
;;TO-DO Rework generate-view to use 3 functions from large-toolbar
|
;;TO-DO Rework generate-view to use 3 functions from large-toolbar
|
||||||
(views/defview profile []
|
(views/defview profile []
|
||||||
(views/letsubs [list-ref (reagent/atom nil)
|
(views/letsubs [list-ref (reagent/atom nil)
|
||||||
contact [:contacts/current-contact]]
|
{:keys [ens-verified name] :as contact} [:contacts/current-contact]]
|
||||||
(when contact
|
(when contact
|
||||||
(let [header-in-toolbar (header-in-toolbar contact)
|
(let [header-in-toolbar (header-in-toolbar contact)
|
||||||
header (header contact)
|
header (header (cond-> contact
|
||||||
|
(and ens-verified name)
|
||||||
|
(assoc :usernames [name])))
|
||||||
content
|
content
|
||||||
[[list/action-list (actions contact)
|
[[list/action-list (actions contact)
|
||||||
{:container-style styles/action-container
|
{:container-style styles/action-container
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.ui.components.common.styles :as common.styles]
|
[status-im.ui.components.common.styles :as common.styles]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.utils.utils :as utils]))
|
[status-im.utils.utils :as utils]
|
||||||
|
[status-im.ui.components.list-item.views :as list-item]))
|
||||||
|
|
||||||
(defn group-chat-profile-toolbar [admin?]
|
(defn group-chat-profile-toolbar [admin?]
|
||||||
[toolbar/toolbar {}
|
[toolbar/toolbar {}
|
||||||
|
@ -33,21 +34,6 @@
|
||||||
:accessibility-label :done-button}
|
:accessibility-label :done-button}
|
||||||
(i18n/label :t/done)]])
|
(i18n/label :t/done)]])
|
||||||
|
|
||||||
(defn actions [allow-adding-members? chat-id]
|
|
||||||
(concat
|
|
||||||
(when allow-adding-members?
|
|
||||||
[{:label (i18n/label :add-members)
|
|
||||||
:icon :main-icons/add
|
|
||||||
:action #(re-frame/dispatch [:navigate-to :add-participants-toggle-list])}])
|
|
||||||
[{:label (i18n/label :t/clear-history)
|
|
||||||
:icon :main-icons/close
|
|
||||||
:action #(re-frame/dispatch [:chat.ui/clear-history-pressed])
|
|
||||||
:accessibility-label :clear-history-button}
|
|
||||||
{:label (i18n/label :t/delete-chat)
|
|
||||||
:icon :main-icons/arrow-left
|
|
||||||
:action #(re-frame/dispatch [:group-chats.ui/remove-chat-pressed chat-id])
|
|
||||||
:accessibility-label :delete-chat-button}]))
|
|
||||||
|
|
||||||
(defn member-actions [chat-id member us-admin?]
|
(defn member-actions [chat-id member us-admin?]
|
||||||
(concat
|
(concat
|
||||||
[{:action #(re-frame/dispatch [(if platform/desktop? :show-profile-desktop :chat.ui/show-profile) (:public-key member)])
|
[{:action #(re-frame/dispatch [(if platform/desktop? :show-profile-desktop :chat.ui/show-profile) (:public-key member)])
|
||||||
|
@ -61,7 +47,7 @@
|
||||||
:label (i18n/label :t/make-admin)}])))
|
:label (i18n/label :t/make-admin)}])))
|
||||||
|
|
||||||
(defn render-member [chat-id {:keys [name public-key] :as member} admin? current-user-identity]
|
(defn render-member [chat-id {:keys [name public-key] :as member} admin? current-user-identity]
|
||||||
[react/view
|
[react/view {:padding-vertical 10}
|
||||||
[contact/contact-view
|
[contact/contact-view
|
||||||
{:contact member
|
{:contact member
|
||||||
:extend-options (member-actions chat-id member admin?)
|
:extend-options (member-actions chat-id member admin?)
|
||||||
|
@ -78,15 +64,13 @@
|
||||||
(defview chat-group-members-view [chat-id admin? current-user-identity]
|
(defview chat-group-members-view [chat-id admin? current-user-identity]
|
||||||
(letsubs [members [:contacts/current-chat-contacts]]
|
(letsubs [members [:contacts/current-chat-contacts]]
|
||||||
(when (seq members)
|
(when (seq members)
|
||||||
[react/view
|
[list/flat-list {:data members
|
||||||
[list/flat-list {:data members
|
:key-fn :address
|
||||||
:separator list/default-separator
|
:render-fn #(render-member chat-id % admin? current-user-identity)}])))
|
||||||
:key-fn :address
|
|
||||||
:render-fn #(render-member chat-id % admin? current-user-identity)}]])))
|
|
||||||
|
|
||||||
(defn members-list [chat-id admin? current-user-identity]
|
(defn members-list [chat-id admin? current-user-identity]
|
||||||
[react/view
|
[react/view
|
||||||
[profile.components/settings-title (i18n/label :t/members-title)]
|
[list-item/list-item {:title :t/members-title :type :section-header}]
|
||||||
[chat-group-members-view chat-id admin? current-user-identity]])
|
[chat-group-members-view chat-id admin? current-user-identity]])
|
||||||
|
|
||||||
(defview group-chat-profile []
|
(defview group-chat-profile []
|
||||||
|
@ -102,20 +86,30 @@
|
||||||
(< (count members) constants/max-group-chat-participants))]
|
(< (count members) constants/max-group-chat-participants))]
|
||||||
[react/view profile.components.styles/profile
|
[react/view profile.components.styles/profile
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
(if editing?
|
;;TODO doesn't work, needs to be fixed
|
||||||
[group-chat-profile-edit-toolbar]
|
;(if editing?
|
||||||
[group-chat-profile-toolbar admin?])
|
;[group-chat-profile-edit-toolbar]
|
||||||
|
[group-chat-profile-toolbar false];admin?]
|
||||||
[react/scroll-view
|
[react/scroll-view
|
||||||
[react/view profile.components.styles/profile-form
|
[react/view profile.components.styles/profile-form
|
||||||
[profile.components/profile-header
|
[profile.components/group-header-display shown-chat]
|
||||||
{:contact shown-chat
|
[react/view {:height 20}]
|
||||||
:editing? editing?
|
(when allow-adding-members?
|
||||||
:allow-icon-change? false
|
[list-item/list-item
|
||||||
:on-change-text-event :group-chats.ui/name-changed}]
|
{:title :t/add-members
|
||||||
[list/action-list (actions allow-adding-members? chat-id)
|
:icon :main-icons/add
|
||||||
{:container-style styles/action-container
|
:theme :action
|
||||||
:action-style styles/action
|
:on-press #(re-frame/dispatch [:navigate-to :add-participants-toggle-list])}])
|
||||||
:action-label-style styles/action-label
|
[list-item/list-item
|
||||||
:action-separator-style styles/action-separator
|
{:title :t/clear-history
|
||||||
:icon-opts styles/action-icon-opts}]
|
:icon :main-icons/close
|
||||||
|
:theme :action
|
||||||
|
:on-press #(re-frame/dispatch [:chat.ui/clear-history-pressed])
|
||||||
|
:accessibility-label :clear-history-button}]
|
||||||
|
[list-item/list-item
|
||||||
|
{:title :t/delete-chat
|
||||||
|
:icon :main-icons/arrow-left
|
||||||
|
:theme :action
|
||||||
|
:on-press #(re-frame/dispatch [:group-chats.ui/remove-chat-pressed chat-id])
|
||||||
|
:accessibility-label :delete-chat-button}]
|
||||||
[members-list chat-id admin? (first admins) current-pk]]]]))))
|
[members-list chat-id admin? (first admins) current-pk]]]]))))
|
||||||
|
|
Loading…
Reference in New Issue