diff --git a/src/status_im/chat/handlers/wallet_chat.cljs b/src/status_im/chat/handlers/wallet_chat.cljs index 02f7ef8196..3fe5718bbf 100644 --- a/src/status_im/chat/handlers/wallet_chat.cljs +++ b/src/status_im/chat/handlers/wallet_chat.cljs @@ -1,7 +1,14 @@ (ns status-im.chat.handlers.wallet-chat (:require [re-frame.core :refer [after enrich path dispatch]] [status-im.utils.handlers :refer [register-handler] :as u] - [status-im.constants :refer [wallet-chat-id]])) + [status-im.constants :refer [wallet-chat-id]] + [clojure.string :as s])) + +(def dapp-contact + {:whisper-identity wallet-chat-id + :name (s/capitalize wallet-chat-id) + :dapp? true}) + (register-handler :init-wallet-chat (u/side-effect! @@ -10,5 +17,6 @@ (dispatch [:add-chat wallet-chat-id {:name "Wallet" - :dapp-url "http://127.0.0.1:3450"}]))))) + :dapp-url "http://127.0.0.1:3450"}]) + (dispatch [:add-contacts [dapp-contact]]))))) diff --git a/src/status_im/components/toolbar/view.cljs b/src/status_im/components/toolbar/view.cljs index db98861020..e1f9d82af5 100644 --- a/src/status_im/components/toolbar/view.cljs +++ b/src/status_im/components/toolbar/view.cljs @@ -32,8 +32,7 @@ :style icon-back}]]]))] (or custom-content [view {:style st/toolbar-title-container} - [text {:style st/toolbar-title-text - :font :medium} + [text {:style st/toolbar-title-text} title]]) [view st/toolbar-actions-container (if actions diff --git a/src/status_im/contacts/screen.cljs b/src/status_im/contacts/screen.cljs index 729bd55492..60fab7c8ea 100644 --- a/src/status_im/contacts/screen.cljs +++ b/src/status_im/contacts/screen.cljs @@ -29,13 +29,13 @@ (defn contact-list-toolbar [] (let [new-contact? (get-in platform-specific [:contacts :new-contact-in-toolbar?]) - actions (cond->> [{:image {:source {:uri :icon_search} - :style icon-search} - :handler (fn [])}] - new-contact? - (into [{:image {:source {:uri :icon_add} - :style icon-search} - :handler #(dispatch [:navigate-to :new-contact])}]))] + actions (cond->> [{:image {:source {:uri :icon_search} + :style icon-search} + :handler (fn [])}] + new-contact? + (into [{:image {:source {:uri :icon_add} + :style icon-search} + :handler #(dispatch [:navigate-to :new-contact])}]))] [toolbar {:nav-action {:image {:source {:uri :icon_hamburger} :style hamburger-icon} :handler open-drawer} @@ -87,8 +87,10 @@ :style create-icon}]]]]) (defn contact-list [] - (let [contacts (subscribe [:get-added-contacts-with-limit contacts-limit]) - contacts-count (subscribe [:added-contacts-count]) + (let [peoples (subscribe [:get-added-people-with-limit contacts-limit]) + dapps (subscribe [:get-added-dapps-with-limit contacts-limit]) + people-count (subscribe [:added-people-count]) + dapps-count (subscribe [:added-dapps-count]) click-handler (subscribe [:get :contacts-click-handler]) show-toolbar-shadow? (r/atom false)] (fn [] @@ -98,23 +100,25 @@ (when @show-toolbar-shadow? [linear-gradient {:style st/contact-group-header-gradient-bottom :colors st/contact-group-header-gradient-bottom-colors}])] - (if (pos? @contacts-count) + (if (pos? (+ @dapps-count @people-count)) [scroll-view {:style st/contact-groups :onScroll (fn [e] (let [offset (.. e -nativeEvent -contentOffset -y)] (reset! show-toolbar-shadow? (<= st/contact-group-header-height offset))))} - [contact-group - @contacts - @contacts-count - (label :t/contacts-group-dapps) - :dapps true - @click-handler] - [contact-group - @contacts - @contacts-count - (label :t/contacts-group-people) - :people false - @click-handler]] + (when (pos? @dapps-count) + [contact-group + @dapps + @dapps-count + (label :t/contacts-group-dapps) + :dapps true + @click-handler]) + (when (pos? @people-count) + [contact-group + @peoples + @people-count + (label :t/contacts-group-people) + :people false + @click-handler])] [view st/empty-contact-groups [react/icon :group_big st/empty-contacts-icon] [text {:style st/empty-contacts-text} (label :t/no-contacts)]]) diff --git a/src/status_im/contacts/subs.cljs b/src/status_im/contacts/subs.cljs index 68aa8cf448..58357b523e 100644 --- a/src/status_im/contacts/subs.cljs +++ b/src/status_im/contacts/subs.cljs @@ -19,18 +19,39 @@ (register-sub :all-added-contacts (fn [db _] (let [contacts (reaction (:contacts @db))] - (->> (remove #(:pending %) @contacts) + (->> (remove :pending @contacts) (sort-contacts) (reaction))))) -(register-sub :get-added-contacts-with-limit - (fn [_ [_ limit]] +(register-sub :all-added-people + (fn [] (let [contacts (subscribe [:all-added-contacts])] + (reaction (remove :dapp? @contacts))))) + +(register-sub :all-added-dapps + (fn [] + (let [contacts (subscribe [:all-added-contacts])] + (reaction (filter :dapp? @contacts))))) + + +(register-sub :get-added-people-with-limit + (fn [_ [_ limit]] + (let [contacts (subscribe [:all-added-people])] (reaction (take limit @contacts))))) -(register-sub :added-contacts-count +(register-sub :get-added-dapps-with-limit + (fn [_ [_ limit]] + (let [contacts (subscribe [:all-added-dapps])] + (reaction (take limit @contacts))))) + +(register-sub :added-people-count (fn [_ _] - (let [contacts (subscribe [:all-added-contacts])] + (let [contacts (subscribe [:all-added-people])] + (reaction (count @contacts))))) + +(register-sub :added-dapps-count + (fn [_ _] + (let [contacts (subscribe [:all-added-dapps])] (reaction (count @contacts))))) (defn get-contact-letter [contact]