Don't do a connection checks when using push notifications
authorFelix Weilbach <felix.weilbach@nextcloud.com>
Wed, 3 Nov 2021 12:53:45 +0000 (13:53 +0100)
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>
Thu, 4 Nov 2021 18:07:22 +0000 (18:07 +0000)
When using push notifications, it is not necessary to do regular
connection checks because the push notifications will take care of it.

Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
src/gui/application.cpp

index 9a7cd6a225fd4d6035f034af491062160406fd8f..f153224b21fb1f5d212c4f4aad02fcd7d046766d 100644 (file)
@@ -34,6 +34,7 @@
 #include "sharedialog.h"
 #include "accountmanager.h"
 #include "creds/abstractcredentials.h"
+#include "pushnotifications.h"
 
 #if defined(BUILD_UPDATER)
 #include "updater/ocupdater.h"
@@ -459,9 +460,10 @@ void Application::slotCheckConnection()
 
         // Don't check if we're manually signed out or
         // when the error is permanent.
-        if (state != AccountState::SignedOut
-            && state != AccountState::ConfigurationError
-            && state != AccountState::AskingCredentials) {
+        const auto pushNotifications = accountState->account()->pushNotifications();
+        const auto pushNotificationsAvailable = (pushNotifications && pushNotifications->isReady());
+        if (state != AccountState::SignedOut && state != AccountState::ConfigurationError
+            && state != AccountState::AskingCredentials && !pushNotificationsAvailable) {
             accountState->checkConnectivity();
         }
     }