Fix for inconsistent gap between messages (#421)

This commit is contained in:
Alexander Pantyuhov 2016-11-07 14:28:20 +03:00
parent b51653fcd8
commit 2843aa2153
2 changed files with 8 additions and 8 deletions

View File

@ -386,7 +386,7 @@
(fn [db [_ {:keys [chat-id clock-value] :as opts}]] (fn [db [_ {:keys [chat-id clock-value] :as opts}]]
(let [chat (if (chats/exists? chat-id) (let [chat (if (chats/exists? chat-id)
(let [{old-clock-value :clock-value :as chat} (chats/get-by-id 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))] (prepare-chat db chat-id opts))]
(chats/save chat) (chats/save chat)
(update-in db [:chats chat-id] merge chat)))) (update-in db [:chats chat-id] merge chat))))

View File

@ -211,8 +211,8 @@
:keypair {:public public-key :keypair {:public public-key
:private private-key}))) :private private-key})))
(protocol/send-message! (assoc-in options (protocol/send-message! (assoc-in options
[:message :to] (:to message)))) [:message :to] (:to message))))))
(dispatch [:inc-clock chat-id])))))) (dispatch [:inc-clock chat-id]))))
(register-handler ::send-command-protocol! (register-handler ::send-command-protocol!
(u/side-effect! (u/side-effect!
@ -235,5 +235,5 @@
:keypair {:public public-key :keypair {:public public-key
:private private-key})) :private private-key}))
(protocol/send-message! (assoc-in options (protocol/send-message! (assoc-in options
[:message :to] chat-id))) [:message :to] chat-id)))))
(dispatch [:inc-clock chat-id]))))))) (dispatch [:inc-clock chat-id])))))