sync activity center

Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
Michele Balistreri 2021-11-30 14:30:24 +03:00
parent 816f15f976
commit 46c023920c
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
3 changed files with 28 additions and 12 deletions

View File

@ -28,7 +28,10 @@
:chat-type constants/one-to-one-chat-type
:chat-name name
:public? false
:group-chat false)))
:group-chat false)
:else
chat))
(defn <-rpc [item]
(-> item

View File

@ -6,15 +6,28 @@
[status-im.data-store.activities :as data-store.activities]))
(fx/defn handle-activities [{:keys [db]} activities]
(let [{:keys [unread-count notifications]}
(reduce (fn [acc {:keys [read dismissed accepted] :as notification}]
(as-> acc a
(if read
(update a :unread-count dec)
(update a :unread-count inc))
(if (or dismissed accepted)
(update a :notifications (fn [items] (remove #(= (:id notification) (:id %)) items)))
(update a :notifications conj notification))))
{:unread-count (get db :activity.center/notifications-count 0)
:notifications (get-in db [:activity.center/notifications :notifications])}
activities)]
{:db (-> db
(update-in [:activity.center/notifications :notifications] #(concat activities %))
(update :activity.center/notifications-count + (count activities)))
(assoc-in [:activity.center/notifications :notifications] notifications)
(assoc :activity.center/notifications-count (max 0 unread-count)))
:dispatch (cond
(= (:view-id db) :notifications-center)
[:mark-all-activity-center-notifications-as-read]
(= (:view-id db) :chat)
[:accept-all-activity-center-notifications-from-chat (:current-chat-id db)])})
[:accept-all-activity-center-notifications-from-chat (:current-chat-id db)])}))
(fx/defn get-activity-center-notifications-count
{:events [:get-activity-center-notifications-count]}

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.91.12",
"commit-sha1": "f60cf5cd47c9f50f1bfb8e01aa5f49802d5220c5",
"src-sha256": "10dwxrav77v7xvbzy9camacdflsvpyjnwry638jhgrd4i32x745f"
"version": "v0.91.14",
"commit-sha1": "0867458f16dc8ddb5a25113083c82fde3b27f148",
"src-sha256": "0l1slzs96glycylsy8cdi20qzabdhwd3j78fwvn4aknxddyyy8fr"
}