Fix merging of :message/message-persisted event

Previously `:message/message-persisted` was dispatched for each incoming
message because its argument was not a vector. The event was renamed to
`:message/messages-persisted`.
This commit is contained in:
Roman Volosovskyi 2019-01-18 13:45:54 +02:00
parent 4981f4c346
commit 8754f72eba
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
4 changed files with 12 additions and 6 deletions

View File

@ -21,4 +21,4 @@
db
statuses)
:data-store/tx [{:transaction (user-statuses-store/save-statuses-tx statuses)
:success-event [:message/message-persisted js-obj]}]})))
:success-event [:message/messages-persisted [js-obj]]}]})))

View File

@ -139,7 +139,8 @@
:data-store/tx [(merge
{:transaction (messages-store/save-message-tx prepared-message)}
(when raw-message
{:success-event [:message/message-persisted raw-message]}))]}
{:success-event
[:message/messages-persisted [raw-message]]}))]}
(when (and platform/desktop?
(not batch?)
(not (system-message? prepared-message)))

View File

@ -66,7 +66,7 @@
[merged-values]))]))))))
(defn- merge-persistence-events [success-events]
(merge-events-of-type success-events :message/message-persisted))
(merge-events-of-type success-events :message/messages-persisted))
(defn- perform-transactions [raw-transactions realm]
(let [success-events (keep :success-event raw-transactions)

View File

@ -791,9 +791,14 @@
(chat.message/update-message-status cofx chat-id message-id status)))
(handlers/register-handler-fx
:message/message-persisted
(fn [cofx [_ raw-message]]
(chat.message/confirm-message-processed cofx raw-message)))
:message/messages-persisted
(fn [cofx [_ raw-messages]]
(apply fx/merge
cofx
(map
(fn [raw-message]
(chat.message/confirm-message-processed raw-message))
raw-messages))))
;; signal module