[Fix] Seen state in Activity Center when it is open (#16541)

This commit fixes the seen state of notifications, if the user is in the Activity Center screen while receiving a new notification.

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2023-07-11 23:29:17 +08:00 committed by GitHub
parent 3fce4816dc
commit 126a8705cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -102,7 +102,10 @@
(rf/defn reconcile-seen-state
{:events [:activity-center/reconcile-seen-state]}
[{:keys [db]} seen?]
{:db (assoc-in db [:activity-center :seen?] seen?)})
(cond-> {:db (assoc-in db [:activity-center :seen?] seen?)}
(= (:view-id db) :activity-center)
(assoc :dispatch [:activity-center/mark-as-seen])))
;;;; Status changes (read/dismissed/deleted)

View File

@ -436,3 +436,19 @@
:type types/one-to-one-chat}
:cursor ""}}}
(events/notifications-fetch-error cofx :dummy-error))))))
(deftest seen-state-test
(testing "update seen state"
(is (= {:db {:activity-center {:seen? true}}}
(events/reconcile-seen-state {:db {}} true))))
(testing "update seen state when the user is on other screen"
(is (= {:db {:view-id :chats-stack
:activity-center {:seen? false}}}
(events/reconcile-seen-state {:db {:view-id :chats-stack}} false))))
(testing "update seen state when the user is on activity center"
(is (= {:db {:view-id :activity-center
:activity-center {:seen? false}}
:dispatch [:activity-center/mark-as-seen]}
(events/reconcile-seen-state {:db {:view-id :activity-center}} false)))))