fix(Widget): Incorrect removing of contacts

pull/6628/head
bodwok 2022-04-26 21:23:15 +03:00 committed by Anthony Bilinski
parent bc8763e835
commit 039f6ff0b3
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
2 changed files with 22 additions and 18 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright © 2014-2019 by The qTox Project Contributors
Copyright © 2014-2022 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
@ -1746,7 +1746,16 @@ void Widget::removeFriend(Friend* f, bool fake)
{
assert(f);
if (!fake) {
removeChatHistory(*f);
RemoveChatDialog ask(this, *f);
ask.exec();
if (!ask.accepted()) {
return;
}
if (ask.removeHistory()) {
profile.getHistory()->removeChatHistory(f->getPersistentId());
}
}
const ToxPk friendPk = f->getPublicKey();
@ -2054,7 +2063,16 @@ void Widget::removeGroup(Group* g, bool fake)
{
assert(g);
if (!fake) {
removeChatHistory(*g);
RemoveChatDialog ask(this, *g);
ask.exec();
if (!ask.accepted()) {
return;
}
if (ask.removeHistory()) {
profile.getHistory()->removeChatHistory(g->getPersistentId());
}
}
const auto& groupId = g->getPersistentId();
@ -2737,17 +2755,3 @@ void Widget::formatWindowTitle(const QString& content)
setWindowTitle(content + " - qTox");
}
}
void Widget::removeChatHistory(Chat& chat)
{
RemoveChatDialog ask(this, chat);
ask.exec();
if (!ask.accepted()) {
return;
}
if (ask.removeHistory()) {
profile.getHistory()->removeChatHistory(chat.getPersistentId());
}
}

View File

@ -90,6 +90,7 @@ class IMessageBoxManager;
class ContentDialogManager;
class FriendList;
class GroupList;
class RemoveChatDialog;
class Widget final : public QMainWindow
{
@ -287,7 +288,6 @@ private:
void cleanupNotificationSound();
void acceptFileTransfer(const ToxFile &file, const QString &path);
void formatWindowTitle(const QString& content);
void removeChatHistory(Chat& chat);
private:
Profile& profile;