Sync clear history

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
frank 2022-02-11 13:51:02 +08:00 committed by Andrea Maria Piana
parent cf734032f2
commit 7b7a86284b
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
3 changed files with 24 additions and 3 deletions

View File

@ -222,3 +222,16 @@
:c2 {:m3 {:chat-id :c2 :message-id :m3} :c2 {:m3 {:chat-id :c2 :message-id :m3}
:m4 {:chat-id :c2 :message-id :m4}}}}} :m4 {:chat-id :c2 :message-id :m4}}}}}
[:m1 :m3])) [:m1 :m3]))
(defn remove-cleared-message [messages cleared-at]
(into {} (remove #(let [message-clock (:clock-value (second %))]
(<= message-clock cleared-at))
messages)))
(fx/defn handle-cleared-histories-messages
{:events [::handle-cleared-hisotories-messages]}
[{:keys [db]} cleared-histories]
{:db (reduce (fn [acc current]
(update-in acc [:messages (:chatId current)] remove-cleared-message (:clearedAt current)))
db
cleared-histories)})

View File

@ -45,6 +45,7 @@
^js removed-messages (.-removedMessages response-js) ^js removed-messages (.-removedMessages response-js)
^js visibility-status-updates (.-statusUpdates response-js) ^js visibility-status-updates (.-statusUpdates response-js)
^js current-visibility-status (.-currentStatus response-js) ^js current-visibility-status (.-currentStatus response-js)
^js cleared-histories (.-clearedHistories response-js)
sync-handler (when-not process-async process-response)] sync-handler (when-not process-async process-response)]
(cond (cond
@ -131,6 +132,13 @@
(process-next response-js sync-handler) (process-next response-js sync-handler)
(models.message/handle-removed-messages removed-messages-clj))) (models.message/handle-removed-messages removed-messages-clj)))
(seq cleared-histories)
(let [cleared-histories-clj (types/js->clj cleared-histories)]
(js-delete response-js "clearedHistories")
(fx/merge cofx
(process-next response-js sync-handler)
(models.message/handle-cleared-histories-messages cleared-histories-clj)))
(seq visibility-status-updates) (seq visibility-status-updates)
(let [visibility-status-updates-clj (types/js->clj visibility-status-updates)] (let [visibility-status-updates-clj (types/js->clj visibility-status-updates)]
(js-delete response-js "statusUpdates") (js-delete response-js "statusUpdates")

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.94.1", "version": "v0.94.3",
"commit-sha1": "1c549f7d714b489473626b2e933c703c2d73299d", "commit-sha1": "07b9c3c7de5e155ef257e729161c101ccc3ead27",
"src-sha256": "1w3rl1n3bb7a4qpa3m27ksqpm2avhdfwchbynphbrnj3rshnfzc5" "src-sha256": "0njp130h3d5k5p694as4y4s012q0s5jwx3p5s98aqj4kh06fyy04"
} }