fix loading of chat's messages

This commit is contained in:
Roman Volosovskyi 2016-05-21 16:32:04 +03:00
parent 277905124d
commit 8bda739201
2 changed files with 11 additions and 11 deletions

View File

@ -285,13 +285,15 @@
(defmethod nav/preload-data! :chat
[{:keys [current-chat-id] :as db} [_ _ id]]
(let [messages (get-in db [:chats current-chat-id :messages])]
(let [chat-id (or id current-chat-id)
messages (get-in db [:chats chat-id :messages])
db' (assoc db :current-chat-id chat-id)]
(println "wuuut..." chat-id messages)
(if (seq messages)
(-> db
(assoc :current-chat-id (or id current-chat-id))
db'
(-> db'
load-messages!
init-chat)
db)))
init-chat))))
(defn prepare-chat
[{:keys [contacts] :as db} [_ contcat-id]]

View File

@ -3,12 +3,10 @@
(:require [re-frame.core :refer [register-sub]]))
(register-sub :selected-participant
(fn [db [_]]
(let [participants (:selected-participants @db)]
(reaction
(when (seq participants)
(let [identity (first participants)]
(get-in @db [:contacts identity])))))))
(fn [db _]
(reaction
(let [identity (first (:selected-participants @db))]
(get-in @db [:contacts identity])))))
(register-sub :group-settings
(fn [db [_ k]]