From 521240cfd60ffaa93cb20e4e8c8bac44bc53040e Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 29 Jul 2025 14:36:46 +0200 Subject: [PATCH] fix #LINQT-1860 refresh unread count on chatroom marked as read --- Linphone/core/chat/ChatCore.cpp | 2 -- Linphone/core/chat/ChatCore.hpp | 1 - Linphone/core/chat/ChatList.cpp | 29 ++++++++++++++++------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Linphone/core/chat/ChatCore.cpp b/Linphone/core/chat/ChatCore.cpp index 9426f703b..27e81a459 100644 --- a/Linphone/core/chat/ChatCore.cpp +++ b/Linphone/core/chat/ChatCore.cpp @@ -139,7 +139,6 @@ ChatCore::ChatCore(const std::shared_ptr &chatRoom) : QObjec ChatCore::~ChatCore() { lDebug() << "[ChatCore] delete" << this; mustBeInMainThread("~" + getClassName()); - mChatModelConnection->disconnect(); emit mChatModel->removeListener(); } @@ -670,7 +669,6 @@ void ChatCore::updateInfo(const std::shared_ptr &updatedFriend if (isThisFriend) { if (isRemoval) { mFriendModel = nullptr; - mFriendModelConnection = nullptr; } int capabilities = mChatModel->getCapabilities(); auto chatroom = mChatModel->getMonitor(); diff --git a/Linphone/core/chat/ChatCore.hpp b/Linphone/core/chat/ChatCore.hpp index 9e93c8ece..c6c2b1fa7 100644 --- a/Linphone/core/chat/ChatCore.hpp +++ b/Linphone/core/chat/ChatCore.hpp @@ -214,7 +214,6 @@ private: std::shared_ptr mFriendModel; QSharedPointer> mChatModelConnection; QSharedPointer> mCoreModelConnection; - QSharedPointer> mFriendModelConnection; DECLARE_ABSTRACT_OBJECT }; diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index c4bf71aef..6fd1d2c3c 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -69,14 +69,17 @@ void ChatList::connectItem(QSharedPointer chat) { emit dataChanged(modelIndex, modelIndex); } }; - connect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, dataChange); + connect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, [this, dataChange] { + dataChange(); + auto defaultAccount = App::getInstance()->getAccountList()->getDefaultAccountCore(); + if (defaultAccount) emit defaultAccount->lRefreshNotifications(); + }); connect(chat.get(), &ChatCore::lastUpdatedTimeChanged, this, dataChange); connect(chat.get(), &ChatCore::lastMessageChanged, this, dataChange); } void ChatList::setSelf(QSharedPointer me) { mModelConnection = SafeConnection::create(me, CoreModel::getInstance()); - mModelConnection->makeConnectToCore(&ChatList::lUpdate, [this]() { mModelConnection->invokeToModel([this]() { mustBeInLinphoneThread(getClassName()); @@ -102,11 +105,11 @@ void ChatList::setSelf(QSharedPointer me) { connectItem(chat); } mustBeInMainThread(getClassName()); - clearData(); - for(auto chat: *chats) { - add(chat); - } - delete chats; + clearData(); + for (auto chat : *chats) { + add(chat); + } + delete chats; }); }); }); @@ -118,21 +121,21 @@ void ChatList::setSelf(QSharedPointer me) { const std::shared_ptr &room, const std::shared_ptr &message) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - auto receiverAccount = ToolModel::findAccount(message->getToAddress()); - if (!receiverAccount) { - qWarning() << log().arg("Receiver account not found in account list, return"); - return; - } - auto receiverAddress = receiverAccount->getContactAddress(); + auto receiverAddress = message->getToAddress(); if (!receiverAddress) { qWarning() << log().arg("Receiver account has no address, return"); return; } + auto senderAddress = message->getFromAddress(); auto defaultAddress = core->getDefaultAccount()->getContactAddress(); if (!defaultAddress->weakEqual(receiverAddress)) { qDebug() << log().arg("Receiver account is not the default one, do not add chat to list"); return; } + if (defaultAddress->weakEqual(senderAddress)) { + qDebug() << log().arg("Sender account is the default one, do not add chat to list"); + return; + } auto chatCore = ChatCore::create(room); mModelConnection->invokeToCore([this, chatCore] {