contacts screen/views

This commit is contained in:
Roman Volosovskyi 2016-05-10 19:06:22 +03:00
parent 544571e3a7
commit f1584b8342
6 changed files with 16 additions and 46 deletions

View File

@ -7,7 +7,7 @@
[syng-im.handlers]
[syng-im.subs]
[syng-im.components.react :refer [navigator app-registry]]
[syng-im.components.contact-list.contact-list :refer [contact-list]]
[syng-im.contacts.screen :refer [contact-list]]
[syng-im.components.discovery.discovery :refer [discovery]]
[syng-im.components.discovery.discovery-tag :refer [discovery-tag]]
[syng-im.chat.screen :refer [chat]]

View File

@ -1,12 +1,12 @@
(ns syng-im.components.contact-list.contact-list
(ns syng-im.contacts.screen
(:require-macros
[natal-shell.data-source :refer [data-source clone-with-rows]]
[natal-shell.core :refer [with-error-view]])
[natal-shell.data-source :refer [data-source clone-with-rows]]
[natal-shell.core :refer [with-error-view]])
(:require [re-frame.core :refer [subscribe dispatch dispatch-sync]]
[syng-im.components.react :refer [view text image touchable-highlight
navigator list-view
list-item]]
[syng-im.components.contact-list.contact :refer [contact-view]]
[syng-im.contacts.views.contact :refer [contact-view]]
[syng-im.components.styles :refer [font
title-font
color-white

View File

@ -1,8 +1,8 @@
(ns syng-im.components.contact-list.contact
(ns syng-im.contacts.views.contact
(:require [syng-im.components.react :refer [view text image touchable-highlight]]
[syng-im.resources :as res]
[syng-im.navigation :as nav]
[syng-im.components.contact-list.contact-inner :refer [contact-inner-view]]))
[syng-im.contacts.views.contact-inner :refer [contact-inner-view]]))
(defn show-chat [navigator whisper-identity]
(nav/nav-push navigator {:view-id :chat}))

View File

@ -1,4 +1,4 @@
(ns syng-im.components.contact-list.contact-inner
(ns syng-im.contacts.views.contact-inner
(:require [clojure.string :as s]
[syng-im.components.react :refer [view image text]]
[syng-im.components.styles :refer [font

View File

@ -3,20 +3,11 @@
[syng-im.persistence.realm :as r]
[syng-im.utils.random :as random :refer [timestamp]]
[clojure.string :refer [join blank?]]
[syng-im.db :as db]
[syng-im.utils.logging :as log]
[syng-im.constants :refer [content-type-status]]
[syng-im.models.messages :refer [save-message]]
[syng-im.persistence.realm-queries :refer [include-query]]))
(defn signal-chats-updated [db]
(update-in db db/updated-chats-signal-path (fn [current]
(if current
(inc current)
0))))
(defn chats-updated? [db]
(get-in db db/updated-chats-signal-path))
(defn chat-name-from-contacts [identities]
(let [chat-name (->> identities
@ -52,8 +43,6 @@
([{:keys [last-msg-id] :as chat}]
(let [chat (assoc chat :last-msg-id (or last-msg-id ""))]
(r/write #(r/create :chats chat))))
([db chat-id identities group-chat?]
(create-chat db chat-id identities group-chat? nil))
([db chat-id identities group-chat? chat-name]
(if (chat-exists? chat-id)
db
@ -72,7 +61,7 @@
:contacts contacts
:last-msg-id ""}))))
(add-status-message chat-id)
(signal-chats-updated db)))))
db))))
(defn chat-contacts [chat-id]
(-> (r/get-by-field :chats :chat-id chat-id)
@ -95,7 +84,7 @@
:is-active true
:name group-name
:contacts contacts} true))))
(signal-chats-updated db))
db)
(defn normalize-contacts
[chats]

View File

@ -1,7 +1,7 @@
(ns syng-im.subs
(:require-macros [reagent.ratom :refer [reaction]])
(:require [re-frame.core :refer [register-sub]]
[syng-im.models.chats :refer [chats-list chats-updated? chat-by-id]]
[syng-im.models.chats :refer [chats-list chat-by-id]]
[syng-im.models.contacts :refer [contacts-list
contacts-list-exclude
contacts-list-include]]
@ -13,10 +13,7 @@
(register-sub :get-chats
(fn [db _]
(let [chats-updated (reaction (chats-updated? @db))]
(reaction
(let [_ @chats-updated]
(chats-list))))))
(reaction (:chats @db))))
;; -- User data --------------------------------------------------------------
@ -26,34 +23,19 @@
;; (reaction
;; (get @db :user-phone-number))))
(register-sub
:get-user-identity
(fn [db _]
(reaction
(get @db :user-identity))))
(register-sub
:get-loading
(fn [db _]
(reaction
(get @db :loading))))
(register-sub
:signed-up
(fn [db _]
(reaction
(get @db :signed-up))))
(reaction (:signed-up @db))))
(register-sub
:get-contacts
(fn [db _]
(reaction
(get @db :contacts))))
(reaction (:contacts @db))))
(register-sub :all-contacts
(fn [db _]
(reaction
(contacts-list))))
(fn [_ _]
(reaction (contacts-list))))
(register-sub :all-new-contacts
(fn [db _]
@ -81,4 +63,3 @@
(register-sub :db
(fn [db _] (reaction @db)))