fix double notification for messages

This commit is contained in:
Gaelle Braud 2025-09-03 12:05:23 +02:00
parent d5841e45ec
commit cbc9c5e2b9
2 changed files with 16 additions and 4 deletions

View file

@ -121,6 +121,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
if (!message) return;
auto receiverAddress = message->getToAddress();
if (!receiverAddress) {
qWarning() << log().arg("Receiver account has no address, return");

View file

@ -526,18 +526,29 @@ void CoreModel::onLogCollectionUploadProgressIndication(const std::shared_ptr<li
void CoreModel::onMessageReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::shared_ptr<linphone::ChatMessage> &message) {
if (message->isOutgoing()) return;
emit unreadNotificationsChanged();
std::list<std::shared_ptr<linphone::ChatMessage>> messages;
messages.push_back(message);
if (App::getInstance()->getNotifier()) App::getInstance()->getNotifier()->notifyReceivedMessages(room, messages);
if (App::getInstance()->getNotifier()) {
App::getInstance()->getNotifier()->notifyReceivedMessages(room, messages);
}
emit messageReceived(core, room, message);
}
void CoreModel::onMessagesReceived(const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ChatRoom> &room,
const std::list<std::shared_ptr<linphone::ChatMessage>> &messages) {
emit unreadNotificationsChanged();
if (App::getInstance()->getNotifier()) App::getInstance()->getNotifier()->notifyReceivedMessages(room, messages);
emit messagesReceived(core, room, messages);
std::list<std::shared_ptr<linphone::ChatMessage>> finalMessages;
for (auto &message : messages) {
if (message->isOutgoing()) continue;
finalMessages.push_back(message);
}
if (finalMessages.size() > 0) {
emit unreadNotificationsChanged();
emit messagesReceived(core, room, finalMessages);
}
if (App::getInstance()->getNotifier())
App::getInstance()->getNotifier()->notifyReceivedMessages(room, finalMessages);
}
void CoreModel::onNewMessageReaction(const std::shared_ptr<linphone::Core> &core,