fix: Marking AC notification as read does not affect correspondent message in chat (#18058)
This commit is contained in:
parent
198a4d74a5
commit
aa89ebdb93
|
@ -45,6 +45,7 @@
|
||||||
{:db (update-in db [:chats chat-id] merge chat)}))
|
{:db (update-in db [:chats chat-id] merge chat)}))
|
||||||
|
|
||||||
(rf/defn load-chat
|
(rf/defn load-chat
|
||||||
|
{:events [:chats-list/load-chat]}
|
||||||
[_ chat-id]
|
[_ chat-id]
|
||||||
{:json-rpc/call [{:method "wakuext_chat"
|
{:json-rpc/call [{:method "wakuext_chat"
|
||||||
:params [chat-id]
|
:params [chat-id]
|
||||||
|
|
|
@ -122,10 +122,13 @@
|
||||||
:on-error [:activity-center/process-notification-failure notification-id
|
:on-error [:activity-center/process-notification-failure notification-id
|
||||||
:notification/mark-as-read]}]}))
|
:notification/mark-as-read]}]}))
|
||||||
|
|
||||||
(rf/defn mark-as-read-success
|
(defn mark-as-read-success
|
||||||
{:events [:activity-center.notifications/mark-as-read-success]}
|
[_ [{:keys [chat-id] :as notification}]]
|
||||||
[cofx notification]
|
{:fx [(when chat-id
|
||||||
(notifications-reconcile cofx [(assoc notification :read true)]))
|
[:dispatch [:chats-list/load-chat chat-id]])
|
||||||
|
[:dispatch [:activity-center.notifications/reconcile [(assoc notification :read true)]]]]})
|
||||||
|
|
||||||
|
(rf/reg-event-fx :activity-center.notifications/mark-as-read-success mark-as-read-success)
|
||||||
|
|
||||||
(rf/defn mark-as-unread
|
(rf/defn mark-as-unread
|
||||||
{:events [:activity-center.notifications/mark-as-unread]}
|
{:events [:activity-center.notifications/mark-as-unread]}
|
||||||
|
|
|
@ -63,16 +63,12 @@
|
||||||
(events/mark-as-read cofx (:id notif)))))))
|
(events/mark-as-read cofx (:id notif)))))))
|
||||||
|
|
||||||
(deftest mark-as-read-success-test
|
(deftest mark-as-read-success-test
|
||||||
(let [f-args (atom [])
|
(let [cofx {:db {}}
|
||||||
cofx {:db {}}
|
notif {:id "0x1" :read false :type types/one-to-one-chat :chat-id "chat-id"}
|
||||||
notif {:id "0x1" :read false :type types/one-to-one-chat}]
|
expected-fx {:fx [[:dispatch [:chats-list/load-chat "chat-id"]]
|
||||||
(with-redefs [events/notifications-reconcile
|
[:dispatch
|
||||||
(fn [& args]
|
[:activity-center.notifications/reconcile [(assoc notif :read true)]]]]}]
|
||||||
(reset! f-args args)
|
(is (match? expected-fx (events/mark-as-read-success cofx [notif])))))
|
||||||
:result)]
|
|
||||||
(is (= :result (events/mark-as-read-success cofx notif)))
|
|
||||||
(is (match? [cofx [(assoc notif :read true)]]
|
|
||||||
@f-args)))))
|
|
||||||
|
|
||||||
(deftest mark-as-unread-test
|
(deftest mark-as-unread-test
|
||||||
(testing "does nothing if the notification ID cannot be found in the app db"
|
(testing "does nothing if the notification ID cannot be found in the app db"
|
||||||
|
|
Loading…
Reference in New Issue