Use new convenience method to check if push notifications ready for account in FilePr...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 13 Mar 2023 16:58:55 +0000 (17:58 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:32 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/macOS/fileproviderdomainmanager_mac.mm

index 4ad17c53c638be9af53c41c694e749905ed85c8a..cf2f470a16fd7dc0f13837a4b7c80ed2dd4b0f42 100644 (file)
@@ -64,6 +64,14 @@ QString accountIdFromDomain(NSFileProviderDomain * const domain)
     return accountIdFromDomainId(domain.identifier);
 }
 
+bool accountFilesPushNotificationsReady(const OCC::AccountPtr &account)
+{
+    const auto pushNotifications = account->pushNotifications();
+    const auto pushNotificationsCapability = account->capabilities().availablePushNotifications() & OCC::PushNotificationType::Files;
+
+    return pushNotificationsCapability && pushNotifications && pushNotifications->isReady();
+}
+
 }
 
 namespace OCC {
@@ -531,12 +539,10 @@ void FileProviderDomainManager::removeFileProviderDomainForAccount(const Account
 
     d->removeFileProviderDomain(accountState);
 
-    const auto pushNotifications = account->pushNotifications();
-    const auto pushNotificationsCapability = account->capabilities().availablePushNotifications() & PushNotificationType::Files;
-
-    if (pushNotificationsCapability && pushNotifications && pushNotifications->isReady()) {
+    if (accountFilesPushNotificationsReady(account)) {
+        const auto pushNotifications = account->pushNotifications();
         disconnect(pushNotifications, &PushNotifications::filesChanged, this, &FileProviderDomainManager::signalEnumeratorChanged);
-    } else if (pushNotificationsCapability) {
+    } else if (const auto hasFilesPushNotificationsCapability = account->capabilities().availablePushNotifications() & PushNotificationType::Files) {
         disconnect(account.get(), &Account::pushNotificationsReady, this, &FileProviderDomainManager::setupPushNotificationsForAccount);
     }
 }