fix loading of chat's messages

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

View File

@ -285,13 +285,15 @@
(defmethod nav/preload-data! :chat (defmethod nav/preload-data! :chat
[{:keys [current-chat-id] :as db} [_ _ id]] [{: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) (if (seq messages)
(-> db db'
(assoc :current-chat-id (or id current-chat-id)) (-> db'
load-messages! load-messages!
init-chat) init-chat))))
db)))
(defn prepare-chat (defn prepare-chat
[{:keys [contacts] :as db} [_ contcat-id]] [{:keys [contacts] :as db} [_ contcat-id]]

View File

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