mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
fix #LINQT-1860 refresh unread count on chatroom marked as read
This commit is contained in:
parent
e90869c781
commit
521240cfd6
3 changed files with 16 additions and 16 deletions
|
|
@ -139,7 +139,6 @@ ChatCore::ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom) : QObjec
|
|||
ChatCore::~ChatCore() {
|
||||
lDebug() << "[ChatCore] delete" << this;
|
||||
mustBeInMainThread("~" + getClassName());
|
||||
mChatModelConnection->disconnect();
|
||||
emit mChatModel->removeListener();
|
||||
}
|
||||
|
||||
|
|
@ -670,7 +669,6 @@ void ChatCore::updateInfo(const std::shared_ptr<linphone::Friend> &updatedFriend
|
|||
if (isThisFriend) {
|
||||
if (isRemoval) {
|
||||
mFriendModel = nullptr;
|
||||
mFriendModelConnection = nullptr;
|
||||
}
|
||||
int capabilities = mChatModel->getCapabilities();
|
||||
auto chatroom = mChatModel->getMonitor();
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ private:
|
|||
std::shared_ptr<FriendModel> mFriendModel;
|
||||
QSharedPointer<SafeConnection<ChatCore, ChatModel>> mChatModelConnection;
|
||||
QSharedPointer<SafeConnection<ChatCore, CoreModel>> mCoreModelConnection;
|
||||
QSharedPointer<SafeConnection<ChatCore, FriendModel>> mFriendModelConnection;
|
||||
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
};
|
||||
|
|
|
|||
|
|
@ -69,14 +69,17 @@ void ChatList::connectItem(QSharedPointer<ChatCore> chat) {
|
|||
emit dataChanged(modelIndex, modelIndex);
|
||||
}
|
||||
};
|
||||
connect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, dataChange);
|
||||
connect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, [this, dataChange] {
|
||||
dataChange();
|
||||
auto defaultAccount = App::getInstance()->getAccountList()->getDefaultAccountCore();
|
||||
if (defaultAccount) emit defaultAccount->lRefreshNotifications();
|
||||
});
|
||||
connect(chat.get(), &ChatCore::lastUpdatedTimeChanged, this, dataChange);
|
||||
connect(chat.get(), &ChatCore::lastMessageChanged, this, dataChange);
|
||||
}
|
||||
|
||||
void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
||||
mModelConnection = SafeConnection<ChatList, CoreModel>::create(me, CoreModel::getInstance());
|
||||
|
||||
mModelConnection->makeConnectToCore(&ChatList::lUpdate, [this]() {
|
||||
mModelConnection->invokeToModel([this]() {
|
||||
mustBeInLinphoneThread(getClassName());
|
||||
|
|
@ -102,11 +105,11 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
|
|||
connectItem(chat);
|
||||
}
|
||||
mustBeInMainThread(getClassName());
|
||||
clearData();
|
||||
for(auto chat: *chats) {
|
||||
add(chat);
|
||||
}
|
||||
delete chats;
|
||||
clearData();
|
||||
for (auto chat : *chats) {
|
||||
add(chat);
|
||||
}
|
||||
delete chats;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -118,21 +121,21 @@ 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));
|
||||
auto receiverAccount = ToolModel::findAccount(message->getToAddress());
|
||||
if (!receiverAccount) {
|
||||
qWarning() << log().arg("Receiver account not found in account list, return");
|
||||
return;
|
||||
}
|
||||
auto receiverAddress = receiverAccount->getContactAddress();
|
||||
auto receiverAddress = message->getToAddress();
|
||||
if (!receiverAddress) {
|
||||
qWarning() << log().arg("Receiver account has no address, return");
|
||||
return;
|
||||
}
|
||||
auto senderAddress = message->getFromAddress();
|
||||
auto defaultAddress = core->getDefaultAccount()->getContactAddress();
|
||||
if (!defaultAddress->weakEqual(receiverAddress)) {
|
||||
qDebug() << log().arg("Receiver account is not the default one, do not add chat to list");
|
||||
return;
|
||||
}
|
||||
if (defaultAddress->weakEqual(senderAddress)) {
|
||||
qDebug() << log().arg("Sender account is the default one, do not add chat to list");
|
||||
return;
|
||||
}
|
||||
|
||||
auto chatCore = ChatCore::create(room);
|
||||
mModelConnection->invokeToCore([this, chatCore] {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue