adjust code to work with 'Contact' - >:contact, fix bug
This commit is contained in:
parent
936c443a63
commit
c6a589bd4b
|
@ -61,8 +61,9 @@
|
|||
(set-initialized true))))
|
||||
|
||||
(register-handler :received-msg
|
||||
(fn [db [_ {chat-id :from
|
||||
msg-id :msg-id :as msg}]]
|
||||
(fn [db [action {chat-id :from
|
||||
msg-id :msg-id :as msg}]]
|
||||
(log/debug action "msg" msg)
|
||||
(save-message chat-id msg)
|
||||
(-> db
|
||||
(create-chat chat-id [chat-id])
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
(defn signal-chat-updated [db chat-id]
|
||||
(update-in db (db/updated-chat-signal-path chat-id) (fn [current]
|
||||
(if current
|
||||
(inc current)
|
||||
0))))
|
||||
(if current
|
||||
(inc current)
|
||||
0))))
|
||||
|
||||
(defn chat-updated? [db chat-id]
|
||||
(->> (db/updated-chat-signal-path chat-id)
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
(:require [syng-im.persistence.realm :as r]
|
||||
[syng-im.utils.random :refer [timestamp]]
|
||||
[clojure.string :refer [join blank?]]
|
||||
[syng-im.db :as db]))
|
||||
[syng-im.db :as db]
|
||||
[syng-im.utils.logging :as log]))
|
||||
|
||||
(defn signal-chats-updated [db]
|
||||
(update-in db db/updated-chats-signal-path (fn [current]
|
||||
|
@ -32,9 +33,11 @@
|
|||
([db chat-id identities]
|
||||
(create-chat db chat-id identities nil))
|
||||
([db chat-id identities chat-name]
|
||||
(when-not (r/exists? :chats :chat-id chat-id)
|
||||
(if (r/exists? :chats :chat-id chat-id)
|
||||
db
|
||||
(let [chat-name (or chat-name
|
||||
(get-chat-name chat-id identities))]
|
||||
(get-chat-name chat-id identities))
|
||||
_ (log/debug "creating chat" chat-name)]
|
||||
(r/write
|
||||
(fn []
|
||||
(let [group-chat? (> (count identities) 1)
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
:whisper-identity "abc"
|
||||
:name "fake"
|
||||
:photo-path ""}]
|
||||
(realm/get-list "Contact")))
|
||||
(realm/get-list :contacts)))
|
||||
|
||||
(defn load-syng-contacts [db]
|
||||
(let [contacts (map (fn [contact]
|
||||
|
@ -61,7 +61,7 @@
|
|||
(assoc db :contacts contacts)))
|
||||
|
||||
(defn- create-contact [{:keys [phone-number whisper-identity name photo-path]}]
|
||||
(realm/create "Contact"
|
||||
(realm/create :contacts
|
||||
{:phone-number phone-number
|
||||
:whisper-identity whisper-identity
|
||||
:name (or name "")
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
(.-length objs))
|
||||
|
||||
(defn get-list [schema-name]
|
||||
(vals (js->clj (.objects realm schema-name) :keywordize-keys true)))
|
||||
(vals (js->clj (.objects realm (to-string schema-name)) :keywordize-keys true)))
|
||||
|
||||
|
||||
(comment
|
||||
|
|
Loading…
Reference in New Issue