Fix contacts sorting

This commit is contained in:
virvar 2016-06-20 12:50:20 +03:00
parent 383602200e
commit c6205fdd65
4 changed files with 12 additions and 9 deletions

View File

@ -63,8 +63,7 @@
:default-chat-icon (st/default-chat-icon-menu-item color)
:default-chat-icon-text st/default-chat-icon-text}])
(defview contact-icon-view [identity styles]
[contact [:contact-by-identity identity]]
(defn contact-icon-view [contact styles]
(let [photo-path (:photo-path contact)
;; TODO stub data
online true]
@ -74,8 +73,8 @@
[default-chat-icon (:name contact) styles])
[contact-online online styles]]))
(defn contact-icon-contacts-tab [identity]
[contact-icon-view identity
(defn contact-icon-contacts-tab [contact]
[contact-icon-view contact
{:container st/container-chat-list
:online-view st/online-view
:online-dot-left st/online-dot-left

View File

@ -60,7 +60,7 @@
[text {:style st/show-all-text} (label :show-all)]]]])
(defn contact-list []
(let [contacts (subscribe [:get-contacts])
(let [contacts (subscribe [:all-contacts])
show-toolbar-shadow? (r/atom false)]
(fn []
[drawer-view

View File

@ -7,10 +7,14 @@
(let [contacts (reaction (:contacts @db))]
(reaction (vals @contacts)))))
(defn sort-contacts [contacts]
(sort-by :name #(compare (clojure.string/lower-case %1)
(clojure.string/lower-case %2)) (vals contacts)))
(register-sub :all-contacts
(fn [db _]
(let [contacts (reaction (:contacts @db))]
(reaction (sort-by :name (vals @contacts))))))
(reaction (sort-contacts @contacts)))))
(defn get-contact-letter [contact]
(when-let [letter (first (:name contact))]
@ -20,7 +24,7 @@
(fn [db _]
(let [contacts (reaction (:contacts @db))]
(reaction
(let [ordered (sort-by :name (vals @contacts))]
(let [ordered (sort-contacts @contacts)]
(map (fn [prev cur]
(let [prev-letter (get-contact-letter prev)
cur-letter (get-contact-letter cur)]

View File

@ -11,9 +11,9 @@
[text {:style st/letter-text}
letter])])
(defn contact-photo [{:keys [whisper-identity]}]
(defn contact-photo [contact]
[view st/contact-photo-container
[contact-icon-contacts-tab whisper-identity]])
[contact-icon-contacts-tab contact]])
(defn contact-inner-view [{:keys [name letter] :as contact}]
[view st/contact-container