From 234a51c97ed0a4051e22050a2c72d0cb2220ef99 Mon Sep 17 00:00:00 2001 From: bitsikka Date: Sat, 2 Mar 2019 00:27:56 +0545 Subject: [PATCH] [#4158] Fix New messages counter being shown for already seen messages Signed-off-by: Pedro Pombeiro --- src/status_im/chat/models.cljs | 3 ++- src/status_im/ui/screens/events.cljs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/status_im/chat/models.cljs b/src/status_im/chat/models.cljs index 001ab283cf..008c3eb0e8 100644 --- a/src/status_im/chat/models.cljs +++ b/src/status_im/chat/models.cljs @@ -246,7 +246,8 @@ {:db (-> (assoc db :current-chat-id chat-id) (set-chat-ui-props {:validation-messages nil}))} (contact-code/listen-to-chat chat-id) - (mark-messages-seen chat-id)))) + (when platform/desktop? + (mark-messages-seen chat-id))))) (fx/defn navigate-to-chat "Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data" diff --git a/src/status_im/ui/screens/events.cljs b/src/status_im/ui/screens/events.cljs index b85431a1ba..0ecd709aa3 100644 --- a/src/status_im/ui/screens/events.cljs +++ b/src/status_im/ui/screens/events.cljs @@ -25,6 +25,7 @@ status-im.utils.keychain.events [re-frame.core :as re-frame] [status-im.hardwallet.core :as hardwallet] + [status-im.chat.models :as chat] [status-im.native-module.core :as status] [status-im.mailserver.core :as mailserver] [status-im.ui.components.permissions :as permissions] @@ -73,6 +74,11 @@ :http-post http-post) +(defn- mark-messages-seen + [{:keys [db] :as cofx}] + (let [{:keys [current-chat-id]} db] + (chat/mark-messages-seen cofx current-chat-id))) + (defn- http-raw-post [{:keys [url body response-validator success-event-creator failure-event-creator timeout-ms opts]}] (let [on-success #(re-frame/dispatch (success-event-creator %)) on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %))) @@ -190,4 +196,5 @@ :hardwallet-connect (hardwallet/hardwallet-connect-screen-did-load %) :hardwallet-authentication-method (hardwallet/authentication-method-screen-did-load %) :accounts (hardwallet/accounts-screen-did-load %) + :chat (mark-messages-seen %) nil))))