clean acc data when acc is changed only when really needed

This commit is contained in:
Martin Rotter 2021-08-16 10:52:36 +02:00
parent 81530935b7
commit 4f6ec40356
5 changed files with 32 additions and 5 deletions

View File

@ -30,6 +30,9 @@ void FormEditFeedlyAccount::apply() {
account<FeedlyServiceRoot>()->network()->oauth()->logout(false);
#endif
bool using_another_acc =
m_details->m_ui.m_txtUsername->lineEdit()->text() !=account<FeedlyServiceRoot>()->network()->username();
account<FeedlyServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
account<FeedlyServiceRoot>()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_checkDownloadOnlyUnreadMessages->isChecked());
account<FeedlyServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
@ -39,7 +42,10 @@ void FormEditFeedlyAccount::apply() {
accept();
if (!m_creatingNew) {
account<FeedlyServiceRoot>()->completelyRemoveAllData();
if (using_another_acc) {
account<FeedlyServiceRoot>()->completelyRemoveAllData();
}
account<FeedlyServiceRoot>()->start(true);
}
}

View File

@ -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<GmailServiceRoot>()->network()->username();
// Make sure that the data copied from GUI are used for brand new login.
account<GmailServiceRoot>()->network()->oauth()->logout(false);
account<GmailServiceRoot>()->network()->oauth()->setClientId(m_details->m_ui.m_txtAppId->lineEdit()->text());
@ -40,7 +43,10 @@ void FormEditGmailAccount::apply() {
accept();
if (!m_creatingNew) {
account<GmailServiceRoot>()->completelyRemoveAllData();
if (using_another_acc) {
account<GmailServiceRoot>()->completelyRemoveAllData();
}
account<GmailServiceRoot>()->start(true);
}
}

View File

@ -25,6 +25,10 @@ void FormEditGreaderAccount::apply() {
FormAccountDetails::apply();
GreaderServiceRoot* existing_root = account<GreaderServiceRoot>();
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);
}
}

View File

@ -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<OwnCloudServiceRoot>()->network()->authUsername() ||
m_details->m_ui.m_txtUrl->lineEdit()->text() != account<OwnCloudServiceRoot>()->network()->url();
account<OwnCloudServiceRoot>()->network()->setUrl(m_details->m_ui.m_txtUrl->lineEdit()->text());
account<OwnCloudServiceRoot>()->network()->setAuthUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
account<OwnCloudServiceRoot>()->network()->setAuthPassword(m_details->m_ui.m_txtPassword->lineEdit()->text());
@ -33,7 +37,7 @@ void FormEditOwnCloudAccount::apply() {
account<OwnCloudServiceRoot>()->saveAccountDataToDatabase();
accept();
if (!m_creatingNew) {
if (!m_creatingNew && using_another_acc) {
account<OwnCloudServiceRoot>()->completelyRemoveAllData();
account<OwnCloudServiceRoot>()->start(true);
}

View File

@ -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<TtRssServiceRoot>()->network()->username() ||
m_details->m_ui.m_txtUrl->lineEdit()->text() != account<TtRssServiceRoot>()->network()->url();
account<TtRssServiceRoot>()->network()->logout(m_account->networkProxy());
account<TtRssServiceRoot>()->network()->setUrl(m_details->m_ui.m_txtUrl->lineEdit()->text());
account<TtRssServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
@ -34,7 +38,7 @@ void FormEditTtRssAccount::apply() {
account<TtRssServiceRoot>()->saveAccountDataToDatabase();
accept();
if (!m_creatingNew) {
if (!m_creatingNew && using_another_acc) {
account<TtRssServiceRoot>()->completelyRemoveAllData();
account<TtRssServiceRoot>()->start(true);
}