parent
c371400f3d
commit
d275382e47
|
@ -1,7 +1,14 @@
|
||||||
(ns status-im.chat.handlers.wallet-chat
|
(ns status-im.chat.handlers.wallet-chat
|
||||||
(:require [re-frame.core :refer [after enrich path dispatch]]
|
(:require [re-frame.core :refer [after enrich path dispatch]]
|
||||||
[status-im.utils.handlers :refer [register-handler] :as u]
|
[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
|
(register-handler :init-wallet-chat
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
@ -10,5 +17,6 @@
|
||||||
(dispatch [:add-chat
|
(dispatch [:add-chat
|
||||||
wallet-chat-id
|
wallet-chat-id
|
||||||
{:name "Wallet"
|
{:name "Wallet"
|
||||||
:dapp-url "http://127.0.0.1:3450"}])))))
|
:dapp-url "http://127.0.0.1:3450"}])
|
||||||
|
(dispatch [:add-contacts [dapp-contact]])))))
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
:style icon-back}]]]))]
|
:style icon-back}]]]))]
|
||||||
(or custom-content
|
(or custom-content
|
||||||
[view {:style st/toolbar-title-container}
|
[view {:style st/toolbar-title-container}
|
||||||
[text {:style st/toolbar-title-text
|
[text {:style st/toolbar-title-text}
|
||||||
:font :medium}
|
|
||||||
title]])
|
title]])
|
||||||
[view st/toolbar-actions-container
|
[view st/toolbar-actions-container
|
||||||
(if actions
|
(if actions
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
|
|
||||||
(defn contact-list-toolbar []
|
(defn contact-list-toolbar []
|
||||||
(let [new-contact? (get-in platform-specific [:contacts :new-contact-in-toolbar?])
|
(let [new-contact? (get-in platform-specific [:contacts :new-contact-in-toolbar?])
|
||||||
actions (cond->> [{:image {:source {:uri :icon_search}
|
actions (cond->> [{:image {:source {:uri :icon_search}
|
||||||
:style icon-search}
|
:style icon-search}
|
||||||
:handler (fn [])}]
|
:handler (fn [])}]
|
||||||
new-contact?
|
new-contact?
|
||||||
(into [{:image {:source {:uri :icon_add}
|
(into [{:image {:source {:uri :icon_add}
|
||||||
:style icon-search}
|
:style icon-search}
|
||||||
:handler #(dispatch [:navigate-to :new-contact])}]))]
|
:handler #(dispatch [:navigate-to :new-contact])}]))]
|
||||||
[toolbar {:nav-action {:image {:source {:uri :icon_hamburger}
|
[toolbar {:nav-action {:image {:source {:uri :icon_hamburger}
|
||||||
:style hamburger-icon}
|
:style hamburger-icon}
|
||||||
:handler open-drawer}
|
:handler open-drawer}
|
||||||
|
@ -87,8 +87,10 @@
|
||||||
:style create-icon}]]]])
|
:style create-icon}]]]])
|
||||||
|
|
||||||
(defn contact-list []
|
(defn contact-list []
|
||||||
(let [contacts (subscribe [:get-added-contacts-with-limit contacts-limit])
|
(let [peoples (subscribe [:get-added-people-with-limit contacts-limit])
|
||||||
contacts-count (subscribe [:added-contacts-count])
|
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])
|
click-handler (subscribe [:get :contacts-click-handler])
|
||||||
show-toolbar-shadow? (r/atom false)]
|
show-toolbar-shadow? (r/atom false)]
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -98,23 +100,25 @@
|
||||||
(when @show-toolbar-shadow?
|
(when @show-toolbar-shadow?
|
||||||
[linear-gradient {:style st/contact-group-header-gradient-bottom
|
[linear-gradient {:style st/contact-group-header-gradient-bottom
|
||||||
:colors st/contact-group-header-gradient-bottom-colors}])]
|
:colors st/contact-group-header-gradient-bottom-colors}])]
|
||||||
(if (pos? @contacts-count)
|
(if (pos? (+ @dapps-count @people-count))
|
||||||
[scroll-view {:style st/contact-groups
|
[scroll-view {:style st/contact-groups
|
||||||
:onScroll (fn [e]
|
:onScroll (fn [e]
|
||||||
(let [offset (.. e -nativeEvent -contentOffset -y)]
|
(let [offset (.. e -nativeEvent -contentOffset -y)]
|
||||||
(reset! show-toolbar-shadow? (<= st/contact-group-header-height offset))))}
|
(reset! show-toolbar-shadow? (<= st/contact-group-header-height offset))))}
|
||||||
[contact-group
|
(when (pos? @dapps-count)
|
||||||
@contacts
|
[contact-group
|
||||||
@contacts-count
|
@dapps
|
||||||
(label :t/contacts-group-dapps)
|
@dapps-count
|
||||||
:dapps true
|
(label :t/contacts-group-dapps)
|
||||||
@click-handler]
|
:dapps true
|
||||||
[contact-group
|
@click-handler])
|
||||||
@contacts
|
(when (pos? @people-count)
|
||||||
@contacts-count
|
[contact-group
|
||||||
(label :t/contacts-group-people)
|
@peoples
|
||||||
:people false
|
@people-count
|
||||||
@click-handler]]
|
(label :t/contacts-group-people)
|
||||||
|
:people false
|
||||||
|
@click-handler])]
|
||||||
[view st/empty-contact-groups
|
[view st/empty-contact-groups
|
||||||
[react/icon :group_big st/empty-contacts-icon]
|
[react/icon :group_big st/empty-contacts-icon]
|
||||||
[text {:style st/empty-contacts-text} (label :t/no-contacts)]])
|
[text {:style st/empty-contacts-text} (label :t/no-contacts)]])
|
||||||
|
|
|
@ -19,18 +19,39 @@
|
||||||
(register-sub :all-added-contacts
|
(register-sub :all-added-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [contacts (reaction (:contacts @db))]
|
(let [contacts (reaction (:contacts @db))]
|
||||||
(->> (remove #(:pending %) @contacts)
|
(->> (remove :pending @contacts)
|
||||||
(sort-contacts)
|
(sort-contacts)
|
||||||
(reaction)))))
|
(reaction)))))
|
||||||
|
|
||||||
(register-sub :get-added-contacts-with-limit
|
(register-sub :all-added-people
|
||||||
(fn [_ [_ limit]]
|
(fn []
|
||||||
(let [contacts (subscribe [:all-added-contacts])]
|
(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)))))
|
(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 [_ _]
|
(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)))))
|
(reaction (count @contacts)))))
|
||||||
|
|
||||||
(defn get-contact-letter [contact]
|
(defn get-contact-letter [contact]
|
||||||
|
|
Loading…
Reference in New Issue