From 4f6ec403568ac26caaf4d08a069808ded165b43f Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 16 Aug 2021 10:52:36 +0200 Subject: [PATCH] clean acc data when acc is changed only when really needed --- .../services/feedly/gui/formeditfeedlyaccount.cpp | 8 +++++++- .../services/gmail/gui/formeditgmailaccount.cpp | 8 +++++++- .../services/greader/gui/formeditgreaderaccount.cpp | 9 ++++++++- .../services/owncloud/gui/formeditowncloudaccount.cpp | 6 +++++- .../services/tt-rss/gui/formeditttrssaccount.cpp | 6 +++++- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp index 4f85d6648..ba82e3e60 100755 --- a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp +++ b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp @@ -30,6 +30,9 @@ void FormEditFeedlyAccount::apply() { account()->network()->oauth()->logout(false); #endif + bool using_another_acc = + m_details->m_ui.m_txtUsername->lineEdit()->text() !=account()->network()->username(); + account()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); account()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_checkDownloadOnlyUnreadMessages->isChecked()); account()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); @@ -39,7 +42,10 @@ void FormEditFeedlyAccount::apply() { accept(); if (!m_creatingNew) { - account()->completelyRemoveAllData(); + if (using_another_acc) { + account()->completelyRemoveAllData(); + } + account()->start(true); } } diff --git a/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp b/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp index c1a561c3f..941784c73 100644 --- a/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp +++ b/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp @@ -25,6 +25,9 @@ FormEditGmailAccount::FormEditGmailAccount(QWidget* parent) void FormEditGmailAccount::apply() { FormAccountDetails::apply(); + bool using_another_acc = + m_details->m_ui.m_txtUsername->lineEdit()->text() !=account()->network()->username(); + // Make sure that the data copied from GUI are used for brand new login. account()->network()->oauth()->logout(false); account()->network()->oauth()->setClientId(m_details->m_ui.m_txtAppId->lineEdit()->text()); @@ -40,7 +43,10 @@ void FormEditGmailAccount::apply() { accept(); if (!m_creatingNew) { - account()->completelyRemoveAllData(); + if (using_another_acc) { + account()->completelyRemoveAllData(); + } + account()->start(true); } } diff --git a/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp b/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp index b56e76f7f..0d399c75e 100755 --- a/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp +++ b/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp @@ -25,6 +25,10 @@ void FormEditGreaderAccount::apply() { FormAccountDetails::apply(); GreaderServiceRoot* existing_root = account(); + bool using_another_acc = + m_details->m_ui.m_txtUsername->lineEdit()->text() != existing_root->network()->username() || + m_details->service() != existing_root->network()->service() || + m_details->m_ui.m_txtUrl->lineEdit()->text() != existing_root->network()->baseUrl(); existing_root->network()->setBaseUrl(m_details->m_ui.m_txtUrl->lineEdit()->text()); existing_root->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); @@ -48,7 +52,10 @@ void FormEditGreaderAccount::apply() { accept(); if (!m_creatingNew) { - existing_root->completelyRemoveAllData(); + if (using_another_acc) { + existing_root->completelyRemoveAllData(); + } + existing_root->start(true); } } diff --git a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp index cf97811a8..610a20ef7 100644 --- a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp +++ b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp @@ -23,6 +23,10 @@ FormEditOwnCloudAccount::FormEditOwnCloudAccount(QWidget* parent) void FormEditOwnCloudAccount::apply() { FormAccountDetails::apply(); + bool using_another_acc = + m_details->m_ui.m_txtUsername->lineEdit()->text() != account()->network()->authUsername() || + m_details->m_ui.m_txtUrl->lineEdit()->text() != account()->network()->url(); + account()->network()->setUrl(m_details->m_ui.m_txtUrl->lineEdit()->text()); account()->network()->setAuthUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); account()->network()->setAuthPassword(m_details->m_ui.m_txtPassword->lineEdit()->text()); @@ -33,7 +37,7 @@ void FormEditOwnCloudAccount::apply() { account()->saveAccountDataToDatabase(); accept(); - if (!m_creatingNew) { + if (!m_creatingNew && using_another_acc) { account()->completelyRemoveAllData(); account()->start(true); } diff --git a/src/librssguard/services/tt-rss/gui/formeditttrssaccount.cpp b/src/librssguard/services/tt-rss/gui/formeditttrssaccount.cpp index 2c5ea951c..04d644fcf 100644 --- a/src/librssguard/services/tt-rss/gui/formeditttrssaccount.cpp +++ b/src/librssguard/services/tt-rss/gui/formeditttrssaccount.cpp @@ -20,6 +20,10 @@ FormEditTtRssAccount::FormEditTtRssAccount(QWidget* parent) void FormEditTtRssAccount::apply() { FormAccountDetails::apply(); + bool using_another_acc = + m_details->m_ui.m_txtUsername->lineEdit()->text() != account()->network()->username() || + m_details->m_ui.m_txtUrl->lineEdit()->text() != account()->network()->url(); + account()->network()->logout(m_account->networkProxy()); account()->network()->setUrl(m_details->m_ui.m_txtUrl->lineEdit()->text()); account()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); @@ -34,7 +38,7 @@ void FormEditTtRssAccount::apply() { account()->saveAccountDataToDatabase(); accept(); - if (!m_creatingNew) { + if (!m_creatingNew && using_another_acc) { account()->completelyRemoveAllData(); account()->start(true); }