mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1489'
Removes chat history of friend when removed, fixes #1486
This commit is contained in:
commit
a232e5afd6
|
@ -138,6 +138,24 @@ HistoryKeeper::~HistoryKeeper()
|
|||
delete db;
|
||||
}
|
||||
|
||||
void HistoryKeeper::removeFriendHistory(const QString& chat)
|
||||
{
|
||||
int chat_id = getChatID(chat, ctSingle).first;
|
||||
|
||||
db->exec("BEGIN TRANSACTION;");
|
||||
|
||||
QString cmd = QString("DELETE FROM chats WHERE name = '%1';").arg(chat);
|
||||
db->exec(cmd);
|
||||
cmd = QString("DELETE FROM aliases WHERE user_id = '%1';").arg(chat);
|
||||
db->exec(cmd);
|
||||
cmd = QString("DELETE FROM sent_status WHERE id IN (SELECT id FROM history WHERE chat_id = '%1');").arg(chat_id);
|
||||
db->exec(cmd);
|
||||
cmd = QString("DELETE FROM history WHERE chat_id = '%1';").arg(chat_id);
|
||||
db->exec(cmd);
|
||||
|
||||
db->exec("COMMIT TRANSACTION;");
|
||||
}
|
||||
|
||||
qint64 HistoryKeeper::addChatEntry(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent)
|
||||
{
|
||||
QList<QString> cmds = generateAddChatEntryCmd(chat, message, sender, dt, isSent);
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
static bool removeHistory(int encrypted = -1);
|
||||
static QList<HistMessage> exportMessagesDeleteFile(int encrypted = -1);
|
||||
|
||||
void removeFriendHistory(const QString& chat);
|
||||
qint64 addChatEntry(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent);
|
||||
qint64 addGroupChatEntry(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt);
|
||||
QList<HistMessage> getChatHistory(ChatType ct, const QString &chat, const QDateTime &time_from, const QDateTime &time_to);
|
||||
|
|
|
@ -866,6 +866,7 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||
}
|
||||
FriendList::removeFriend(f->getFriendID(), fake);
|
||||
Nexus::getCore()->removeFriend(f->getFriendID(), fake);
|
||||
HistoryKeeper::getInstance()->removeFriendHistory(f->getToxID().publicKey);
|
||||
delete f;
|
||||
if (ui->mainHead->layout()->isEmpty())
|
||||
onAddClicked();
|
||||
|
|
Loading…
Reference in New Issue
Block a user