From a292d0ef0dce8edebf2dc100417dd186d6340ba6 Mon Sep 17 00:00:00 2001 From: Wescoeur Date: Mon, 26 Jun 2017 20:17:06 +0200 Subject: [PATCH] fix(ChatModel): compute correctly composing when chat room is set --- src/components/chat/ChatModel.cpp | 18 +++++++++++------- src/components/chat/ChatModel.hpp | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/chat/ChatModel.cpp b/src/components/chat/ChatModel.cpp index 1fa18e341..d56098b07 100644 --- a/src/components/chat/ChatModel.cpp +++ b/src/components/chat/ChatModel.cpp @@ -282,6 +282,7 @@ void ChatModel::setSipAddress (const QString &sipAddress) { shared_ptr core = CoreManager::getInstance()->getCore(); mChatRoom = core->getChatRoomFromUri(::Utils::appStringToCoreString(sipAddress)); + updateIsRemoteComposing(); if (mChatRoom->getUnreadMessagesCount() > 0) resetMessagesCount(); @@ -649,6 +650,14 @@ void ChatModel::resetMessagesCount () { emit messagesCountReset(); } +void ChatModel::updateIsRemoteComposing () { + bool isRemoteComposing = mChatRoom->isRemoteComposing(); + if (isRemoteComposing != mIsRemoteComposing) { + mIsRemoteComposing = isRemoteComposing; + emit isRemoteComposingChanged(mIsRemoteComposing); + } +} + // ----------------------------------------------------------------------------- void ChatModel::handleCallStateChanged (const shared_ptr &call, linphone::CallState state) { @@ -660,13 +669,8 @@ void ChatModel::handleCallStateChanged (const shared_ptr &call, } void ChatModel::handleIsComposingChanged (const shared_ptr &chatRoom) { - if (mChatRoom == chatRoom) { - bool isRemoteComposing = mChatRoom->isRemoteComposing(); - if (isRemoteComposing != mIsRemoteComposing) { - mIsRemoteComposing = isRemoteComposing; - emit isRemoteComposingChanged(mIsRemoteComposing); - } - } + if (mChatRoom == chatRoom) + updateIsRemoteComposing(); } void ChatModel::handleMessageReceived (const shared_ptr &message) { diff --git a/src/components/chat/ChatModel.hpp b/src/components/chat/ChatModel.hpp index 1111e722f..e9ad2496e 100644 --- a/src/components/chat/ChatModel.hpp +++ b/src/components/chat/ChatModel.hpp @@ -137,6 +137,8 @@ private: void resetMessagesCount (); + void updateIsRemoteComposing (); + void handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state); void handleIsComposingChanged (const std::shared_ptr &chatRoom); void handleMessageReceived (const std::shared_ptr &message);