mirror of
https://github.com/status-im/status-react.git
synced 2025-02-19 22:28:40 +00:00
Fix disappearing of the last notification when paired
This commit is contained in:
parent
959df25c02
commit
24ef84b890
@ -12,7 +12,16 @@
|
|||||||
|
|
||||||
(fx/defn handle-activities [{:keys [db]} activities]
|
(fx/defn handle-activities [{:keys [db]} activities]
|
||||||
(let [{:keys [unread-count notifications]}
|
(let [{:keys [unread-count notifications]}
|
||||||
(reduce (fn [acc {:keys [read dismissed accepted] :as notification}]
|
(reduce (fn [acc {:keys [read dismissed accepted chat-id] :as notification}]
|
||||||
|
(if (= "" chat-id)
|
||||||
|
;; TODO(rasom): sometimes messages come with empty `chat-id`s
|
||||||
|
;; (specifically it happens on `SyncActivityCenterRead` message).
|
||||||
|
;; In result, if notification is received with notification center
|
||||||
|
;; screen opened, and there is another paired device online, the
|
||||||
|
;; last notification disappear from the screen and is shown only
|
||||||
|
;; after reopening. It likely makes sense to fix it on status-go
|
||||||
|
;; side, but I got lost a bit.
|
||||||
|
acc
|
||||||
(let [index-existing (->> (map-indexed vector (:notifications acc))
|
(let [index-existing (->> (map-indexed vector (:notifications acc))
|
||||||
(filter (fn [[idx {:keys [id]}]] (= id (:id notification))))
|
(filter (fn [[idx {:keys [id]}]] (= id (:id notification))))
|
||||||
first
|
first
|
||||||
@ -30,7 +39,7 @@
|
|||||||
;; Replace element
|
;; Replace element
|
||||||
(do
|
(do
|
||||||
(assoc-in a [:notifications index-existing] notification)))
|
(assoc-in a [:notifications index-existing] notification)))
|
||||||
(update a :notifications conj notification)))))
|
(update a :notifications conj notification))))))
|
||||||
{:unread-count (get db :activity.center/notifications-count 0)
|
{:unread-count (get db :activity.center/notifications-count 0)
|
||||||
:notifications (into [] (get-in db [:activity.center/notifications :notifications]))}
|
:notifications (into [] (get-in db [:activity.center/notifications :notifications]))}
|
||||||
activities)]
|
activities)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user