]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
improve again state tracking with terms of service app
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 23 Oct 2024 09:22:28 +0000 (11:22 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 23 Oct 2024 16:20:08 +0000 (18:20 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/accountstate.cpp
src/gui/accountstate.h
src/gui/owncloudgui.cpp
src/gui/owncloudgui.h

index 1324fa1dd2c81dba270d5ec77d84ba9823b57ff8..e2fb2779413bd030b21036ca5660b86dd6512be8 100644 (file)
@@ -359,12 +359,7 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
         return;
     }
 
-    if ((_lastConnectionValidatorStatus == ConnectionValidator::NeedToSignTermsOfService && status == ConnectionValidator::Connected) ||
-        (status == ConnectionValidator::NeedToSignTermsOfService && _lastConnectionValidatorStatus != status)) {
-
-        emit termsOfServiceChanged(_account);
-    }
-
+    const auto oldConnectionValidatorStatus = _lastConnectionValidatorStatus;
     _lastConnectionValidatorStatus = status;
 
     // Come online gradually from 503, captive portal(redirection) or maintenance mode
@@ -449,6 +444,12 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta
         setState(NeedToSignTermsOfService);
         break;
     }
+
+    if ((oldConnectionValidatorStatus == ConnectionValidator::NeedToSignTermsOfService && status == ConnectionValidator::Connected) ||
+        (status == ConnectionValidator::NeedToSignTermsOfService && oldConnectionValidatorStatus != status)) {
+
+        emit termsOfServiceChanged(_account, status == ConnectionValidator::NeedToSignTermsOfService ? AccountState::NeedToSignTermsOfService : AccountState::Connected);
+    }
 }
 
 void AccountState::slotHandleRemoteWipeCheck()
index fb306545c36745befe18e71475fde10db3d9b829..de4311dbe605967e0c7f20e1a6b47e0c6d443132 100644 (file)
@@ -195,7 +195,7 @@ signals:
     void hasFetchedNavigationApps();
     void statusChanged();
     void desktopNotificationsAllowedChanged();
-    void termsOfServiceChanged(OCC::AccountPtr account);
+    void termsOfServiceChanged(OCC::AccountPtr account, AccountState::State state);
 
 protected Q_SLOTS:
     void slotConnectionValidatorResult(OCC::ConnectionValidator::Status status, const QStringList &errors);
index abd1b6ec9cacc6563201125959b8bf7b06a4481d..52536d77add5005b7e3f83eb44f52dbd7c2306ad 100644 (file)
@@ -285,14 +285,17 @@ void ownCloudGui::slotTrayMessageIfServerUnsupported(Account *account)
     }
 }
 
-void ownCloudGui::slotNeedToAcceptTermsOfService(OCC::AccountPtr account)
-{
-    slotShowTrayMessage(
-        tr("Terms of service"),
-        tr("Your account %1 requires you to accept the terms of service of your server. "
-           "You will be redirected to %2 to acknowledge that you have read it and agrees with it.")
-            .arg(account->displayName(), account->url().toString()));
-    QDesktopServices::openUrl(account->url());
+void ownCloudGui::slotNeedToAcceptTermsOfService(OCC::AccountPtr account,
+                                                 AccountState::State state)
+{
+    if (state == AccountState::NeedToSignTermsOfService) {
+        slotShowTrayMessage(
+            tr("Terms of service"),
+            tr("Your account %1 requires you to accept the terms of service of your server. "
+               "You will be redirected to %2 to acknowledge that you have read it and agrees with it.")
+                .arg(account->displayName(), account->url().toString()));
+        QDesktopServices::openUrl(account->url());
+    }
 }
 
 void ownCloudGui::slotComputeOverallSyncStatus()
index 1cfc44876d5255e5fa92d9f8a60c8e5f19a439f7..2370d9d3f5614993ddea55302518488b5c25473d 100644 (file)
@@ -94,7 +94,8 @@ public slots:
     void slotOpenPath(const QString &path);
     void slotAccountStateChanged();
     void slotTrayMessageIfServerUnsupported(OCC::Account *account);
-    void slotNeedToAcceptTermsOfService(OCC::AccountPtr account);
+    void slotNeedToAcceptTermsOfService(OCC::AccountPtr account,
+                                        OCC::AccountState::State state);
 
     /**
      * Open a share dialog for a file or folder.