From bb2718824c9ee148b54d2605de6bbba9de544fad Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 13 Mar 2023 17:58:55 +0100 Subject: [PATCH] Use new convenience method to check if push notifications ready for account in FileProviderDomainManager Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderdomainmanager_mac.mm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index 4ad17c53c..cf2f470a1 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -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); } } -- 2.30.2