diff --git a/src/status_im/chat/models/loading.cljs b/src/status_im/chat/models/loading.cljs index 622671d9c2..b5b89761a5 100644 --- a/src/status_im/chat/models/loading.cljs +++ b/src/status_im/chat/models/loading.cljs @@ -45,6 +45,7 @@ {:db (update-in db [:chats chat-id] merge chat)})) (rf/defn load-chat + {:events [:chats-list/load-chat]} [_ chat-id] {:json-rpc/call [{:method "wakuext_chat" :params [chat-id] diff --git a/src/status_im2/contexts/shell/activity_center/events.cljs b/src/status_im2/contexts/shell/activity_center/events.cljs index e0274d6648..4d368579ae 100644 --- a/src/status_im2/contexts/shell/activity_center/events.cljs +++ b/src/status_im2/contexts/shell/activity_center/events.cljs @@ -122,10 +122,13 @@ :on-error [:activity-center/process-notification-failure notification-id :notification/mark-as-read]}]})) -(rf/defn mark-as-read-success - {:events [:activity-center.notifications/mark-as-read-success]} - [cofx notification] - (notifications-reconcile cofx [(assoc notification :read true)])) +(defn mark-as-read-success + [_ [{:keys [chat-id] :as notification}]] + {:fx [(when chat-id + [: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 {:events [:activity-center.notifications/mark-as-unread]} diff --git a/src/status_im2/contexts/shell/activity_center/events_test.cljs b/src/status_im2/contexts/shell/activity_center/events_test.cljs index 4fdc4ec1f4..8f0028e24a 100644 --- a/src/status_im2/contexts/shell/activity_center/events_test.cljs +++ b/src/status_im2/contexts/shell/activity_center/events_test.cljs @@ -63,16 +63,12 @@ (events/mark-as-read cofx (:id notif))))))) (deftest mark-as-read-success-test - (let [f-args (atom []) - cofx {:db {}} - notif {:id "0x1" :read false :type types/one-to-one-chat}] - (with-redefs [events/notifications-reconcile - (fn [& args] - (reset! f-args args) - :result)] - (is (= :result (events/mark-as-read-success cofx notif))) - (is (match? [cofx [(assoc notif :read true)]] - @f-args))))) + (let [cofx {:db {}} + notif {:id "0x1" :read false :type types/one-to-one-chat :chat-id "chat-id"} + expected-fx {:fx [[:dispatch [:chats-list/load-chat "chat-id"]] + [:dispatch + [:activity-center.notifications/reconcile [(assoc notif :read true)]]]]}] + (is (match? expected-fx (events/mark-as-read-success cofx [notif]))))) (deftest mark-as-unread-test (testing "does nothing if the notification ID cannot be found in the app db"