Merge pull request #328 from status-im/bug/contacts-list
Fixes bugs related to contacts list screen (#316, #292)
This commit is contained in:
commit
49e6738626
|
@ -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
|
||||||
|
|
|
@ -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))))}
|
||||||
|
(when (pos? @dapps-count)
|
||||||
[contact-group
|
[contact-group
|
||||||
@contacts
|
@dapps
|
||||||
@contacts-count
|
@dapps-count
|
||||||
(label :t/contacts-group-dapps)
|
(label :t/contacts-group-dapps)
|
||||||
:dapps true
|
:dapps true
|
||||||
@click-handler]
|
@click-handler])
|
||||||
|
(when (pos? @people-count)
|
||||||
[contact-group
|
[contact-group
|
||||||
@contacts
|
@peoples
|
||||||
@contacts-count
|
@people-count
|
||||||
(label :t/contacts-group-people)
|
(label :t/contacts-group-people)
|
||||||
:people false
|
:people false
|
||||||
@click-handler]]
|
@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