From 3e574fd65fdc4d8b8864a5cd4e6823fd2f8f79a5 Mon Sep 17 00:00:00 2001 From: alwx Date: Wed, 30 Nov 2016 17:14:37 +0300 Subject: [PATCH] Several messaging fixes: latest message (#507), no more clock-value bugs, some UI fixes --- src/status_im/accounts/screen.cljs | 1 + src/status_im/chat/handlers.cljs | 17 ++++++++--------- src/status_im/chat/views/message.cljs | 3 +-- src/status_im/chats_list/styles.cljs | 3 ++- src/status_im/data_store/messages.cljs | 7 ++++--- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/status_im/accounts/screen.cljs b/src/status_im/accounts/screen.cljs index 6052c46da0..cf56699740 100644 --- a/src/status_im/accounts/screen.cljs +++ b/src/status_im/accounts/screen.cljs @@ -70,6 +70,7 @@ [list-view {:dataSource (lw/to-datasource accounts) :enableEmptySections true :renderRow render-row + :bounces false :style st/account-list :contentContainerStyle (st/account-list-content (count accounts))}] [view st/bottom-actions-container diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index d7d1f14046..cde582708b 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -14,6 +14,7 @@ content-type-command content-type-command-request default-number-of-messages + console-chat-id wallet-chat-id]] [status-im.utils.random :as random] [status-im.chat.sign-up :as sign-up-service] @@ -27,7 +28,6 @@ status-im.chat.handlers.commands [status-im.commands.utils :refer [command-prefix]] [status-im.chat.utils :refer [console? not-console?]] - [status-im.constants :refer [console-chat-id]] [status-im.utils.gfycat.core :refer [generate-gfy]] status-im.chat.handlers.animation status-im.chat.handlers.requests @@ -215,7 +215,6 @@ (-> db (assoc :new-chat new-chat) (update :chats assoc console-chat-id new-chat) - (update :chats-ids conj console-chat-id) (assoc :current-chat-id console-chat-id))))))) (register-handler :init-console-chat @@ -298,7 +297,6 @@ (-> db (assoc :chats chats') - (assoc :chats-ids ids) (dissoc :loaded-chats) (init-console-chat true)))) @@ -376,14 +374,15 @@ [db [_ chat-id chat]] (assoc db :new-chat (prepare-chat db chat-id chat))) -(defn add-chat [{:keys [new-chat] :as db} [_ chat-id]] - (-> db - (update :chats assoc chat-id new-chat) - (update :chats-ids conj chat-id))) +(defn add-chat [{:keys [new-chat chats] :as db} [_ chat-id]] + (if-not (get chats chat-id) + (update db :chats assoc chat-id new-chat) + db)) (defn save-new-chat! - [{:keys [new-chat]} _] - (chats/save new-chat)) + [{{:keys [chat-id] :as new-chat} :new-chat} _] + (when-not (chats/exists? chat-id) + (chats/save new-chat))) (defn open-chat! [_ [_ chat-id _ navigation-type]] diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index 397f8ee3e3..7353b0afb2 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -376,8 +376,7 @@ :from from :message-id message-id}]))) :reagent-render - (fn [{:keys [outgoing group-chat] :as message}] - (log/debug "I HAVE A MESSAGE: " message) + (fn [{:keys [outgoing group-chat clock-value] :as message}] [message-container message [view (let [incoming-group (and group-chat (not outgoing))] diff --git a/src/status_im/chats_list/styles.cljs b/src/status_im/chats_list/styles.cljs index 04f667ffb5..3149b50dd1 100644 --- a/src/status_im/chats_list/styles.cljs +++ b/src/status_im/chats_list/styles.cljs @@ -114,7 +114,8 @@ {:flex 1}) (def list-container - {:background-color color-light-gray}) + {:background-color color-light-gray + :margin-bottom 72}) (def create-icon {:fontSize 20 diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index 3db0985f70..6a7092e2e3 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -84,9 +84,10 @@ [{:keys [chats] :as db} chat-id] (if-let [message (first (get-in db [:chats chat-id :messages]))] message - (let [{:keys [content-type] :as message} (data-store/get-last-message chat-id)] - (when (and message (command-type? content-type)) - (clojure.core/update message :content str-to-map))))) + (if-let [{:keys [content-type] :as message} (data-store/get-last-message chat-id)] + (if (command-type? content-type) + (clojure.core/update message :content str-to-map) + message)))) (defn get-unviewed []