From 080b206e4a6d0f0ef596b1c2384e571dd4cb4ef2 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 12 Aug 2020 17:05:54 +0200 Subject: [PATCH] - Reset all counts when requested - Add an interface to reset count when the GUI need it - Replace handler event name to be more specific on what it is doing and make a new connection when ChatModel request to reset the count --- linphone-app/src/components/chat/ChatModel.cpp | 5 ++--- linphone-app/src/components/chat/ChatProxyModel.cpp | 8 +++++--- linphone-app/src/components/chat/ChatProxyModel.hpp | 2 ++ .../event-count-notifier/AbstractEventCountNotifier.cpp | 9 ++++++--- .../event-count-notifier/AbstractEventCountNotifier.hpp | 2 +- linphone-app/ui/views/App/Main/Conversation.qml | 1 + 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/linphone-app/src/components/chat/ChatModel.cpp b/linphone-app/src/components/chat/ChatModel.cpp index d50d576eb..89b43b022 100644 --- a/linphone-app/src/components/chat/ChatModel.cpp +++ b/linphone-app/src/components/chat/ChatModel.cpp @@ -638,9 +638,8 @@ void ChatModel::compose () { void ChatModel::resetMessageCount () { if (mChatRoom->getUnreadMessagesCount() > 0){ mChatRoom->markAsRead();// Marking as read is only for messages. Not for calls. - emit messageCountReset(); - }else if (CoreManager::getInstance()->getMissedCallCount(getPeerAddress(), getLocalAddress())>0) - emit messageCountReset(); + } + emit messageCountReset(); } // ----------------------------------------------------------------------------- diff --git a/linphone-app/src/components/chat/ChatProxyModel.cpp b/linphone-app/src/components/chat/ChatProxyModel.cpp index 025ec4778..97370fd08 100644 --- a/linphone-app/src/components/chat/ChatProxyModel.cpp +++ b/linphone-app/src/components/chat/ChatProxyModel.cpp @@ -209,8 +209,6 @@ void ChatProxyModel::reload () { mChatModel = CoreManager::getInstance()->getChatModel(mPeerAddress, mLocalAddress); if (mChatModel) { - mChatModel->resetMessageCount(); - mChatModel->focused(); ChatModel *chatModel = mChatModel.get(); QObject::connect(chatModel, &ChatModel::isRemoteComposingChanged, this, &ChatProxyModel::handleIsRemoteComposingChanged); @@ -220,7 +218,11 @@ void ChatProxyModel::reload () { static_cast(sourceModel())->setSourceModel(mChatModel.get()); } - +void ChatProxyModel::resetMessageCount(){ + if( mChatModel){ + mChatModel->resetMessageCount(); + } +} // ----------------------------------------------------------------------------- static inline QWindow *getParentWindow (QObject *object) { diff --git a/linphone-app/src/components/chat/ChatProxyModel.hpp b/linphone-app/src/components/chat/ChatProxyModel.hpp index 7f41e4574..9ab97e3e9 100644 --- a/linphone-app/src/components/chat/ChatProxyModel.hpp +++ b/linphone-app/src/components/chat/ChatProxyModel.hpp @@ -60,6 +60,8 @@ public: Q_INVOKABLE void compose (); + Q_INVOKABLE void resetMessageCount(); + signals: void peerAddressChanged (const QString &peerAddress); void localAddressChanged (const QString &localAddress); diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp index 575ddb05d..54f62b3e5 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -98,18 +98,21 @@ void AbstractEventCountNotifier::handleChatModelCreated (const shared_ptrgetPeerAddress()), Utils::cleanSipAddress(chatModel->getLocalAddress()) }); if (it != mMissedCalls.cend()) { mMissedCalls.erase(it); internalnotifyEventCount(); } } - void AbstractEventCountNotifier::handleCallMissed (CallModel *callModel) { ++mMissedCalls[{ Utils::cleanSipAddress(callModel->getPeerAddress()), Utils::cleanSipAddress(callModel->getLocalAddress()) }]; internalnotifyEventCount(); diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp index 923640323..54c4270f8 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp @@ -68,7 +68,7 @@ private: void handleChatModelCreated (const std::shared_ptr &chatModel); - void handleChatModelFocused (ChatModel *chatModel); + void handleResetMissedCalls (ChatModel *chatModel); void handleCallMissed (CallModel *callModel); QHash mMissedCalls; diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index 26320e079..ec69c541a 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -168,6 +168,7 @@ ColumnLayout { if (!SettingsModel.chatEnabled) { setEntryTypeFilter(ChatModel.CallEntry) } + resetMessageCount() } peerAddress: conversation.peerAddress