mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
small code unification
This commit is contained in:
parent
000eb8977d
commit
bac485400e
|
@ -106,6 +106,17 @@ bool PrivacyForm::setChatLogsPassword()
|
||||||
|
|
||||||
void PrivacyForm::onEncryptLogsUpdated()
|
void PrivacyForm::onEncryptLogsUpdated()
|
||||||
{
|
{
|
||||||
|
auto getOldMessages = []()
|
||||||
|
{
|
||||||
|
auto msgs = HistoryKeeper::getInstance()->exportMessages();
|
||||||
|
qDebug() << "Loaded messages:" << msgs.size();
|
||||||
|
bool delRet = HistoryKeeper::removeHistory();
|
||||||
|
if (!delRet)
|
||||||
|
qWarning() << "HistoryKeeper::removeHistory() returned FALSE";
|
||||||
|
HistoryKeeper::resetInstance(); // HistoryKeeper::removeHistory() invokes HistoryKeeper::removeHistory() but logic may be changed
|
||||||
|
return msgs;
|
||||||
|
};
|
||||||
|
|
||||||
Core* core = Core::getInstance();
|
Core* core = Core::getInstance();
|
||||||
QList<HistoryKeeper::HistMessage> oldMessages;
|
QList<HistoryKeeper::HistMessage> oldMessages;
|
||||||
|
|
||||||
|
@ -115,12 +126,7 @@ void PrivacyForm::onEncryptLogsUpdated()
|
||||||
{
|
{
|
||||||
if (setChatLogsPassword())
|
if (setChatLogsPassword())
|
||||||
{
|
{
|
||||||
oldMessages = HistoryKeeper::getInstance()->exportMessages();
|
oldMessages = getOldMessages();
|
||||||
qDebug() << "Loaded messages:" << oldMessages.size();
|
|
||||||
bool delRet = HistoryKeeper::removeHistory();
|
|
||||||
if (!delRet)
|
|
||||||
qWarning() << "HistoryKeeper::removeHistory() returned FALSE";
|
|
||||||
HistoryKeeper::resetInstance(); // HistoryKeeper::removeHistory() invokes HistoryKeeper::removeHistory() but logic may be changed
|
|
||||||
|
|
||||||
Settings::getInstance().setEncryptLogs(true);
|
Settings::getInstance().setEncryptLogs(true);
|
||||||
bodyUI->cbEncryptHistory->setChecked(true);
|
bodyUI->cbEncryptHistory->setChecked(true);
|
||||||
|
@ -136,12 +142,7 @@ void PrivacyForm::onEncryptLogsUpdated()
|
||||||
{
|
{
|
||||||
if (checkContinue(tr("Old encrypted chat logs", "title"), tr("Would you like to un-encrypt your chat logs?\nOtherwise they will be deleted.")))
|
if (checkContinue(tr("Old encrypted chat logs", "title"), tr("Would you like to un-encrypt your chat logs?\nOtherwise they will be deleted.")))
|
||||||
{
|
{
|
||||||
oldMessages = HistoryKeeper::getInstance()->exportMessages();
|
oldMessages = getOldMessages();
|
||||||
qDebug() << "Loaded messages:" << oldMessages.size();
|
|
||||||
bool delRet = HistoryKeeper::removeHistory();
|
|
||||||
if (!delRet)
|
|
||||||
qWarning() << "HistoryKeeper::removeHistory() returned FALSE";
|
|
||||||
HistoryKeeper::resetInstance(); // HistoryKeeper::removeHistory() invokes HistoryKeeper::removeHistory() but logic may be changed
|
|
||||||
|
|
||||||
Settings::getInstance().setEncryptLogs(false);
|
Settings::getInstance().setEncryptLogs(false);
|
||||||
HistoryKeeper::getInstance()->importMessages(oldMessages);
|
HistoryKeeper::getInstance()->importMessages(oldMessages);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user