fix(SipAddressesModel): check if message is outgoing when cache is updated

This commit is contained in:
Ronan Abhamon 2018-08-28 17:19:46 +02:00
parent b99b078ee0
commit 184b084382
2 changed files with 10 additions and 4 deletions

View file

@ -71,7 +71,7 @@ SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(pare
QObject::connect(coreHandlers, &CoreHandlers::messageReceived, this, &SipAddressesModel::handleMessageReceived);
QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &SipAddressesModel::handleCallStateChanged);
QObject::connect(coreHandlers, &CoreHandlers::presenceReceived, this, &SipAddressesModel::handlePresenceReceived);
QObject::connect(coreHandlers, &CoreHandlers::isComposingChanged, this, &SipAddressesModel::handlerIsComposingChanged);
QObject::connect(coreHandlers, &CoreHandlers::isComposingChanged, this, &SipAddressesModel::handleIsComposingChanged);
}
// -----------------------------------------------------------------------------
@ -409,7 +409,7 @@ void SipAddressesModel::handleMessageSent (const shared_ptr<linphone::ChatMessag
addOrUpdateSipAddress(localAddress, message);
}
void SipAddressesModel::handlerIsComposingChanged (const shared_ptr<linphone::ChatRoom> &chatRoom) {
void SipAddressesModel::handleIsComposingChanged (const shared_ptr<linphone::ChatRoom> &chatRoom) {
auto it = mPeerAddressToSipAddressEntry.find(
Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly())
);
@ -455,7 +455,13 @@ void SipAddressesModel::addOrUpdateSipAddress (SipAddressEntry &sipAddressEntry,
shared_ptr<linphone::ChatRoom> chatRoom(message->getChatRoom());
int count = chatRoom->getUnreadMessagesCount();
QString localAddress(Utils::coreStringToAppString(chatRoom->getLocalAddress()->asStringUriOnly()));
QString localAddress(Utils::coreStringToAppString(
message->isOutgoing()
? chatRoom->getPeerAddress()->asStringUriOnly()
: chatRoom->getLocalAddress()->asStringUriOnly()
));
qInfo() << QStringLiteral("Update (`%1`, `%2`) from chat message.").arg(sipAddressEntry.sipAddress, localAddress);
ConferenceEntry &conferenceEntry = sipAddressEntry.localAddressToConferenceEntry[localAddress];
conferenceEntry.timestamp = QDateTime::fromMSecsSinceEpoch(message->getTime() * 1000);
conferenceEntry.unreadMessageCount = count;

View file

@ -104,7 +104,7 @@ private:
void handleMessageSent (const std::shared_ptr<linphone::ChatMessage> &message);
void handlerIsComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
void handleIsComposingChanged (const std::shared_ptr<linphone::ChatRoom> &chatRoom);
// ---------------------------------------------------------------------------