Fix contacts sync

This commit is contained in:
virvar 2016-03-18 12:53:13 +03:00
parent b10b44988c
commit fcba2679f4
2 changed files with 12 additions and 7 deletions

View File

@ -5,7 +5,7 @@
[messenger.utils.utils :refer [log toast http-post]]
[messenger.utils.database :as db]))
(def fake-contacts? true)
(def fake-contacts? false)
(def react-native-contacts (js/require "react-native-contacts"))
@ -32,7 +32,8 @@
:contacts
(when (not error)
(map (fn [contact]
(merge (generate-contact 1)
(merge contact
(generate-contact 1)
{:name (:givenName contact)
:photo-path (:thumbnailPath contact)
:phone-numbers (:phoneNumbers contact)}))

View File

@ -2,12 +2,18 @@
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [clojure.string :as cstr]
[cljs.core.async :as async :refer [chan put! <!]]
[messenger.utils.utils :refer [log on-error http-post]]
[messenger.utils.utils :refer [log on-error http-post toast]]
[messenger.utils.crypt :refer [encrypt]]
[messenger.comm.intercom :as intercom :refer [save-user-phone-number]]
[messenger.models.contacts :as contacts-model]
[syng-im.utils.logging :as log]))
(set! js/PhoneNumber (js/require "awesome-phonenumber"))
(def country-code "US")
(defn- format-phone-number [number]
(str (.getNumber (js/PhoneNumber. number country-code "international"))))
(defn- get-contact-name [phone-contact]
(cstr/join " "
(filter #(not (cstr/blank? %))
@ -30,7 +36,7 @@
(let [numbers-info (reduce (fn [numbers contact]
(into numbers
(map (fn [c]
{:number (:number c)
{:number (format-phone-number (:number c))
:contact contact})
(:phone-numbers contact))))
'()
@ -62,9 +68,7 @@
(handler))))))
(defn- load-syng-contacts []
(contacts-model/load-syng-contacts)
;; TODO handle contacts
)
(contacts-model/load-syng-contacts))
(defmulti contacts (fn [state id args]