From 2843aa2153bc68d26d3e3dcb7efa58a73868092e Mon Sep 17 00:00:00 2001 From: Alexander Pantyuhov Date: Mon, 7 Nov 2016 14:28:20 +0300 Subject: [PATCH] Fix for inconsistent gap between messages (#421) --- src/status_im/chat/handlers.cljs | 2 +- src/status_im/chat/handlers/send_message.cljs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index 7fff61210c..635d9b7d87 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -386,7 +386,7 @@ (fn [db [_ {:keys [chat-id clock-value] :as opts}]] (let [chat (if (chats/exists? chat-id) (let [{old-clock-value :clock-value :as chat} (chats/get-by-id chat-id)] - (assoc chat :clock-value (+ (max old-clock-value clock-value)) 1)) + (assoc chat :clock-value (max old-clock-value clock-value))) (prepare-chat db chat-id opts))] (chats/save chat) (update-in db [:chats chat-id] merge chat)))) diff --git a/src/status_im/chat/handlers/send_message.cljs b/src/status_im/chat/handlers/send_message.cljs index 97786953f3..37d61a20e2 100644 --- a/src/status_im/chat/handlers/send_message.cljs +++ b/src/status_im/chat/handlers/send_message.cljs @@ -211,8 +211,8 @@ :keypair {:public public-key :private private-key}))) (protocol/send-message! (assoc-in options - [:message :to] (:to message)))) - (dispatch [:inc-clock chat-id])))))) + [:message :to] (:to message)))))) + (dispatch [:inc-clock chat-id])))) (register-handler ::send-command-protocol! (u/side-effect! @@ -226,14 +226,14 @@ :timestamp (datetime/now-ms) :clock-value clock-value} options {:web3 web3 - :message {:from current-public-key - :message-id message-id - :payload payload}}] + :message {:from current-public-key + :message-id message-id + :payload payload}}] (if group-chat (protocol/send-group-message! (assoc options :group-id chat-id :keypair {:public public-key :private private-key})) (protocol/send-message! (assoc-in options - [:message :to] chat-id))) - (dispatch [:inc-clock chat-id]))))))) + [:message :to] chat-id))))) + (dispatch [:inc-clock chat-id])))))