1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 14:55:43 +02:00

conversationmodel: let the daemon manage the removal

Change-Id: I00e8fd2552aa1e08c03ef8e7dada4629ebdd619d
This commit is contained in:
Sébastien Blin 2022-07-15 15:26:17 -04:00
parent 4a08775082
commit d9432163f6

View file

@ -2580,25 +2580,27 @@ ConversationModelPimpl::slotConversationRemoved(const QString& accountId,
} catch (...) {
}
removeConversation();
if (conversation.mode == conversation::Mode::ONE_TO_ONE) {
removeConversation();
// If it's a 1:1 conversation and we don't have any more conversation
// we can remove the contact
auto conv = storage::getConversationsWithPeer(db, contactUri);
if (conv.empty())
linked.owner.contactModel->removeContact(contactUri, false);
auto contactRemoved = true;
try {
auto& conv = getConversationForPeerUri(contactUri).get();
contactRemoved = !conv.isSwarm();
} catch (...) {}
if (contact.isBanned && conv.empty()) {
if (contact.isBanned && contactRemoved) {
// Add 1:1 conv for banned
auto c = storage::beginConversationWithPeer(db, contactUri);
addConversationWith(c, contactUri, false);
Q_EMIT linked.conversationReady(c, contactUri);
Q_EMIT linked.newConversation(c);
}
} else {
removeConversation();
}
} catch (const std::exception& e) {
qWarning() << e.what();
}