Fix unread chat message count.

This commit is contained in:
Ghislain MARY 2018-04-20 09:13:59 +02:00
parent babbd33142
commit 15b38e3a8b
3 changed files with 13 additions and 1 deletions

View file

@ -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;
}
// -----------------------------------------------------------------------------

View file

@ -48,6 +48,12 @@ Imdn::~Imdn () {
// -----------------------------------------------------------------------------
int Imdn::getDisplayNotificationCount () const {
return static_cast<int>(displayedMessages.size());
}
// -----------------------------------------------------------------------------
void Imdn::notifyDelivery (const shared_ptr<ChatMessage> &message) {
if (find(deliveredMessages.begin(), deliveredMessages.end(), message) == deliveredMessages.end()) {
deliveredMessages.push_back(message);

View file

@ -53,6 +53,8 @@ public:
Imdn (ChatRoom *chatRoom);
~Imdn ();
int getDisplayNotificationCount () const;
void notifyDelivery (const std::shared_ptr<ChatMessage> &message);
void notifyDeliveryError (const std::shared_ptr<ChatMessage> &message, LinphoneReason reason);
void notifyDisplay (const std::shared_ptr<ChatMessage> &message);