diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-04-16 22:34:57 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-04-16 22:34:57 +0300 |
commit | e6808655935169815076fdc7699822d0e22aa077 (patch) | |
tree | 0ef9a1153c7498a6caa9c95bfbbc145cc9db54f2 /src/HistoryViewManager.cc | |
parent | Show the unread message count on the window title (diff) | |
download | nheko-e6808655935169815076fdc7699822d0e22aa077.tar.xz |
Update unread messages for the current room when the app is inactive
Diffstat (limited to '')
-rw-r--r-- | src/HistoryViewManager.cc | 12 |
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); + } } } |