Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 84fc7c38 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #5369 from k9mail/fix_no_push_accounts

Don't start PushService if there are no Push-enabled accounts
parents 00f1d684 1bd3173f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -118,11 +118,12 @@ class PushController internal constructor(
        val backgroundSyncDisabledViaSystem = autoSyncManager.isAutoSyncDisabled
        val backgroundSyncDisabledInApp = K9.backgroundOps == K9.BACKGROUND_OPS.NEVER
        val networkNotAvailable = !connectivityManager.isNetworkAvailable()
        val realPushAccounts = getPushAccounts()

        val pushAccounts = if (backgroundSyncDisabledViaSystem || backgroundSyncDisabledInApp || networkNotAvailable) {
            emptyList()
        } else {
            getPushAccounts()
            realPushAccounts
        }
        val pushAccountUuids = pushAccounts.map { it.uuid }

@@ -155,6 +156,9 @@ class PushController internal constructor(
        }

        when {
            realPushAccounts.isEmpty() -> {
                stopServices()
            }
            backgroundSyncDisabledViaSystem -> {
                setPushNotificationState(WAIT_BACKGROUND_SYNC)
                startServices()