Use new convenience method to check if push notifications ready for account in FileProviderDomainManager

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-03-13 17:58:55 +01:00
Родитель 4901b0653f
Коммит bb2718824c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C839200C384636B0
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -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);
}
}