From cd3c7b392eeed2bfc3bc7e9cd83aaf58a2d384ba Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Wed, 9 Mar 2022 03:45:39 -0800 Subject: [PATCH] feat(UI): Add UI for removing group history --- src/widget/widget.cpp | 30 ++++++++++++++++++++---------- src/widget/widget.h | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index fc3e2e985..5a6b46eaa 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1744,16 +1744,7 @@ void Widget::removeFriend(Friend* f, bool fake) { assert(f); if (!fake) { - RemoveChatDialog ask(this, *f); - ask.exec(); - - if (!ask.accepted()) { - return; - } - - if (ask.removeHistory()) { - profile.getHistory()->removeFriendHistory(f->getPublicKey()); - } + removeChatHistory(*f); } const ToxPk friendPk = f->getPublicKey(); @@ -2059,6 +2050,11 @@ void Widget::onGroupPeerAudioPlaying(int groupnumber, ToxPk peerPk) void Widget::removeGroup(Group* g, bool fake) { + assert(g); + if (!fake) { + removeChatHistory(*g); + } + const auto& groupId = g->getPersistentId(); const auto groupnumber = g->getId(); auto groupWidgetIt = groupWidgets.find(groupId); @@ -2742,3 +2738,17 @@ 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()); + } +} diff --git a/src/widget/widget.h b/src/widget/widget.h index 042165693..eead52c31 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -287,6 +287,7 @@ private: void cleanupNotificationSound(); void acceptFileTransfer(const ToxFile &file, const QString &path); void formatWindowTitle(const QString& content); + void removeChatHistory(Chat& chat); private: Profile& profile;