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
|
||||
(: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]])))))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))))}
|
||||
(when (pos? @dapps-count)
|
||||
[contact-group
|
||||
@contacts
|
||||
@contacts-count
|
||||
@dapps
|
||||
@dapps-count
|
||||
(label :t/contacts-group-dapps)
|
||||
:dapps true
|
||||
@click-handler]
|
||||
@click-handler])
|
||||
(when (pos? @people-count)
|
||||
[contact-group
|
||||
@contacts
|
||||
@contacts-count
|
||||
@peoples
|
||||
@people-count
|
||||
(label :t/contacts-group-people)
|
||||
:people false
|
||||
@click-handler]]
|
||||
@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)]])
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue