sync activity center
Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
parent
816f15f976
commit
46c023920c
|
@ -28,7 +28,10 @@
|
||||||
:chat-type constants/one-to-one-chat-type
|
:chat-type constants/one-to-one-chat-type
|
||||||
:chat-name name
|
:chat-name name
|
||||||
:public? false
|
:public? false
|
||||||
:group-chat false)))
|
:group-chat false)
|
||||||
|
|
||||||
|
:else
|
||||||
|
chat))
|
||||||
|
|
||||||
(defn <-rpc [item]
|
(defn <-rpc [item]
|
||||||
(-> item
|
(-> item
|
||||||
|
|
|
@ -6,15 +6,28 @@
|
||||||
[status-im.data-store.activities :as data-store.activities]))
|
[status-im.data-store.activities :as data-store.activities]))
|
||||||
|
|
||||||
(fx/defn handle-activities [{:keys [db]} activities]
|
(fx/defn handle-activities [{:keys [db]} activities]
|
||||||
{:db (-> db
|
(let [{:keys [unread-count notifications]}
|
||||||
(update-in [:activity.center/notifications :notifications] #(concat activities %))
|
(reduce (fn [acc {:keys [read dismissed accepted] :as notification}]
|
||||||
(update :activity.center/notifications-count + (count activities)))
|
(as-> acc a
|
||||||
:dispatch (cond
|
(if read
|
||||||
(= (:view-id db) :notifications-center)
|
(update a :unread-count dec)
|
||||||
[:mark-all-activity-center-notifications-as-read]
|
(update a :unread-count inc))
|
||||||
|
|
||||||
(= (:view-id db) :chat)
|
(if (or dismissed accepted)
|
||||||
[:accept-all-activity-center-notifications-from-chat (:current-chat-id db)])})
|
(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
|
||||||
|
(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)])}))
|
||||||
|
|
||||||
(fx/defn get-activity-center-notifications-count
|
(fx/defn get-activity-center-notifications-count
|
||||||
{:events [:get-activity-center-notifications-count]}
|
{:events [:get-activity-center-notifications-count]}
|
||||||
|
|
|
@ -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.91.12",
|
"version": "v0.91.14",
|
||||||
"commit-sha1": "f60cf5cd47c9f50f1bfb8e01aa5f49802d5220c5",
|
"commit-sha1": "0867458f16dc8ddb5a25113083c82fde3b27f148",
|
||||||
"src-sha256": "10dwxrav77v7xvbzy9camacdflsvpyjnwry638jhgrd4i32x745f"
|
"src-sha256": "0l1slzs96glycylsy8cdi20qzabdhwd3j78fwvn4aknxddyyy8fr"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue