mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Rework auto mark as read on deleted/terminated chats.
These cases come from a bug when the user may leave the chat room on ack timeout and then, we got persistent unread notification (SDK bug).
This commit is contained in:
parent
b36b90eba6
commit
7cd96583fc
6 changed files with 51 additions and 12 deletions
|
|
@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Crash on exit.
|
||||
- Memory stability.
|
||||
|
||||
## 4.4.5 - 2022-06-06
|
||||
|
||||
### Fixed
|
||||
- Chat rooms may be mark as read while hidden.
|
||||
|
||||
## 4.4.4 - 2022-06-01
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// VisualC++: Windows doesn't have to rewrite min max or else building std::max will fail
|
||||
#define NOMINMAX
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
|
@ -374,6 +377,31 @@ int CoreManager::getMissedCallCount(const QString &peerAddress, const QString &l
|
|||
int CoreManager::getMissedCallCountFromLocal( const QString &localAddress)const{
|
||||
return mEventCountNotifier ? mEventCountNotifier->getMissedCallCountFromLocal(localAddress) : 0;
|
||||
}
|
||||
int CoreManager::getUnreadChatMessage(const std::shared_ptr<const linphone::Address>& accountAddress)const{
|
||||
// Workaround : getUnreadMessagesCount(à doesn't check the sate of chat room so they can be left and still count in unread message (for example because of a bug on ack timeout). Remove these counts from the unread count.
|
||||
std::list<std::shared_ptr<linphone::ChatRoom>> allChatRooms = mCore->getChatRooms();
|
||||
std::list<std::shared_ptr<linphone::Account>> accountsList;
|
||||
int unreadChatMessageCount;
|
||||
if( accountAddress)
|
||||
unreadChatMessageCount = mCore->getUnreadChatMessageCountFromLocal(accountAddress);
|
||||
else {
|
||||
accountsList = mCore->getAccountList();
|
||||
unreadChatMessageCount = mCore->getUnreadChatMessageCountFromActiveLocals();
|
||||
}
|
||||
for(auto chatRoom : allChatRooms){
|
||||
auto account = accountsList.begin();
|
||||
if(!accountAddress){
|
||||
while(account != accountsList.end() && !(*account)->getParams()->getIdentityAddress()->weakEqual(chatRoom->getLocalAddress()))
|
||||
++account;
|
||||
}
|
||||
if( ((!accountAddress && account != accountsList.end()) || (accountAddress && accountAddress->weakEqual(chatRoom->getLocalAddress()) ))
|
||||
&& (chatRoom->getState() == linphone::ChatRoom::State::Terminated || chatRoom->getState() == linphone::ChatRoom::State::Deleted))
|
||||
unreadChatMessageCount -= chatRoom->getUnreadMessagesCount();
|
||||
}
|
||||
unreadChatMessageCount = std::max(0,unreadChatMessageCount);
|
||||
|
||||
return unreadChatMessageCount;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,8 @@ public:
|
|||
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
|
||||
|
||||
int getUnreadChatMessage(const std::shared_ptr<const linphone::Address>& accountAddress = nullptr)const;
|
||||
|
||||
static bool isInstanciated(){return mInstance!=nullptr;}
|
||||
|
||||
Q_INVOKABLE bool isLastRemoteProvisioningGood();
|
||||
|
|
|
|||
|
|
@ -67,8 +67,9 @@ AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObje
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AbstractEventCountNotifier::updateUnreadMessageCount () {
|
||||
mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals();
|
||||
internalnotifyEventCount();
|
||||
auto core = CoreManager::getInstance()->getCore();
|
||||
mUnreadMessageCount = CoreManager::getInstance()->getUnreadChatMessage();
|
||||
internalnotifyEventCount();
|
||||
}
|
||||
|
||||
void AbstractEventCountNotifier::internalnotifyEventCount () {
|
||||
|
|
|
|||
|
|
@ -478,9 +478,12 @@ QVariantList AccountSettingsModel::getAccounts () const {
|
|||
|
||||
if(CoreManager::getInstance()->getSettingsModel()->getShowLocalSipAccount()) {
|
||||
QVariantMap account;
|
||||
account["sipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asStringUriOnly());
|
||||
account["fullSipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asString());
|
||||
account["unreadMessageCount"] = core->getUnreadChatMessageCountFromLocal(core->createPrimaryContactParsed());
|
||||
auto address = core->createPrimaryContactParsed();
|
||||
int unreadChatMessageCount = CoreManager::getInstance()->getUnreadChatMessage(address);
|
||||
|
||||
account["sipAddress"] = Utils::coreStringToAppString(address->asStringUriOnly());
|
||||
account["fullSipAddress"] = Utils::coreStringToAppString(address->asString());
|
||||
account["unreadMessageCount"] = unreadChatMessageCount;
|
||||
account["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(account["sipAddress"].toString());
|
||||
account["proxyConfig"].setValue(nullptr);
|
||||
accounts << account;
|
||||
|
|
@ -488,10 +491,13 @@ QVariantList AccountSettingsModel::getAccounts () const {
|
|||
|
||||
for (const auto &proxyConfig : core->getProxyConfigList()) {
|
||||
QVariantMap account;
|
||||
account["sipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly());
|
||||
account["fullSipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString());
|
||||
|
||||
auto proxyAddress = proxyConfig->getIdentityAddress();
|
||||
int unreadChatMessageCount = CoreManager::getInstance()->getUnreadChatMessage(proxyAddress);
|
||||
account["sipAddress"] = Utils::coreStringToAppString(proxyAddress->asStringUriOnly());
|
||||
account["fullSipAddress"] = Utils::coreStringToAppString(proxyAddress->asString());
|
||||
account["proxyConfig"].setValue(proxyConfig);
|
||||
account["unreadMessageCount"] = proxyConfig->getUnreadChatMessageCount();
|
||||
account["unreadMessageCount"] = unreadChatMessageCount;
|
||||
account["missedCallCount"] = CoreManager::getInstance()->getMissedCallCountFromLocal(account["sipAddress"].toString());
|
||||
accounts << account;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,10 +244,7 @@ void TimelineListModel::updateTimelines () {
|
|||
|
||||
// Clean terminated chat rooms.
|
||||
allChatRooms.remove_if([](std::shared_ptr<linphone::ChatRoom> chatRoom){
|
||||
bool toRemove = chatRoom->getState() == linphone::ChatRoom::State::Terminated || chatRoom->getState() == linphone::ChatRoom::State::Deleted;
|
||||
if( toRemove)
|
||||
chatRoom->markAsRead();
|
||||
return toRemove;
|
||||
return chatRoom->getState() == linphone::ChatRoom::State::Terminated || chatRoom->getState() == linphone::ChatRoom::State::Deleted;
|
||||
});
|
||||
|
||||
//Remove no more chat rooms
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue