summary refs log tree commit diff
path: root/src/HistoryViewManager.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-16 22:34:57 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-16 22:34:57 +0300
commite6808655935169815076fdc7699822d0e22aa077 (patch)
tree0ef9a1153c7498a6caa9c95bfbbc145cc9db54f2 /src/HistoryViewManager.cc
parentShow the unread message count on the window title (diff)
downloadnheko-e6808655935169815076fdc7699822d0e22aa077.tar.xz
Update unread messages for the current room when the app is inactive
Diffstat (limited to 'src/HistoryViewManager.cc')
-rw-r--r--src/HistoryViewManager.cc12
1 files 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 <random> +#include <QApplication> #include <QDebug> #include <QSettings> #include <QStackedWidget> @@ -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); + } } }