summary refs log tree commit diff
path: root/src/ChatPage.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-07 12:00:49 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-07 12:00:49 +0300
commit5aff3e43098f1e730afe0202c737a93e90346c9b (patch)
treeb948f13fb1828d1f1e72c920656244f6806e3f65 /src/ChatPage.cc
parentImplement desktop notification for mac (diff)
downloadnheko-5aff3e43098f1e730afe0202c737a93e90346c9b.tar.xz
Don't send notification for the room that is currently open
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r--src/ChatPage.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ChatPage.cc b/src/ChatPage.cc
index b4691fdd..1f5fa995 100644
--- a/src/ChatPage.cc
+++ b/src/ChatPage.cc
@@ -868,15 +868,18 @@ ChatPage::sendDesktopNotifications(const mtx::responses::Notifications &res)
                         if (!cache_->isNotificationSent(event_id)) {
                                 const auto room_id = QString::fromStdString(item.room_id);
                                 const auto user_id = utils::event_sender(item.event);
-                                const auto body    = utils::event_body(item.event);
 
                                 // We should only sent one notification per event.
                                 cache_->markSentNotification(event_id);
 
+                                // Don't send a notification when the current room is opened.
+                                if (isRoomActive(room_id))
+                                        continue;
+
                                 NotificationsManager::postNotification(
                                   QString::fromStdString(cache_->singleRoomInfo(item.room_id).name),
                                   Cache::displayName(room_id, user_id),
-                                  body);
+                                  utils::event_body(item.event));
                         }
                 } catch (const lmdb::error &e) {
                         qWarning() << e.what();