diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 30e0a8843..69e1e3f94 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -416,7 +416,11 @@ int ChatRoom::getChatMessageCount () const { } int ChatRoom::getUnreadChatMessageCount () const { - return getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId()); + L_D(); + int dbUnreadCount = getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId()); + int notifiedCount = d->imdnHandler->getDisplayNotificationCount(); + L_ASSERT(dbUnreadCount >= notifiedCount); + return dbUnreadCount - notifiedCount; } // ----------------------------------------------------------------------------- diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 6cccf52f0..b538cf015 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -48,6 +48,12 @@ Imdn::~Imdn () { // ----------------------------------------------------------------------------- +int Imdn::getDisplayNotificationCount () const { + return static_cast(displayedMessages.size()); +} + +// ----------------------------------------------------------------------------- + void Imdn::notifyDelivery (const shared_ptr &message) { if (find(deliveredMessages.begin(), deliveredMessages.end(), message) == deliveredMessages.end()) { deliveredMessages.push_back(message); diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index 0d1b00940..cf8c46eb8 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -53,6 +53,8 @@ public: Imdn (ChatRoom *chatRoom); ~Imdn (); + int getDisplayNotificationCount () const; + void notifyDelivery (const std::shared_ptr &message); void notifyDeliveryError (const std::shared_ptr &message, LinphoneReason reason); void notifyDisplay (const std::shared_ptr &message);