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]
|
||||
(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))
|
||||
(filter (fn [[idx {:keys [id]}]] (= id (:id notification))))
|
||||
first
|
||||
|
@ -30,7 +39,7 @@
|
|||
;; Replace element
|
||||
(do
|
||||
(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)
|
||||
:notifications (into [] (get-in db [:activity.center/notifications :notifications]))}
|
||||
activities)]
|
||||
|
|
Loading…
Reference in New Issue