From 8bda73920150ec96d177635479a718db122157ca Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Sat, 21 May 2016 16:32:04 +0300 Subject: [PATCH] fix loading of chat's messages --- src/status_im/chat/handlers.cljs | 12 +++++++----- src/status_im/group_settings/subs.cljs | 10 ++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index e7e7ed1621..29ccd437a1 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -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]] diff --git a/src/status_im/group_settings/subs.cljs b/src/status_im/group_settings/subs.cljs index ee9ad34c8a..f2b6ac1db3 100644 --- a/src/status_im/group_settings/subs.cljs +++ b/src/status_im/group_settings/subs.cljs @@ -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]]