From e6808655935169815076fdc7699822d0e22aa077 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sun, 16 Apr 2017 22:34:57 +0300 Subject: [PATCH] Update unread messages for the current room when the app is inactive --- src/HistoryViewManager.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/HistoryViewManager.cc b/src/HistoryViewManager.cc index 1b1244f4..c6d33e02 100644 --- a/src/HistoryViewManager.cc +++ b/src/HistoryViewManager.cc @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -108,9 +109,14 @@ void HistoryViewManager::sync(const Rooms &rooms) int msgs_added = view->addEvents(events); - // TODO: Take into account window focus - if (msgs_added > 0 && roomid != active_room_.id()) - emit unreadMessages(roomid, msgs_added); + if (msgs_added > 0) { + // TODO: When window gets active the current + // unread count (if any) should be cleared. + auto isAppActive = QApplication::activeWindow() != nullptr; + + if (roomid != active_room_.id() || !isAppActive) + emit unreadMessages(roomid, msgs_added); + } } }