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

Commit a0ce6d21 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Block inbox sync on network quite period

If network quite preference is enabled & in the middle of the period, we want to disable inbox folder sync. Same inbox folder sync method can be called, when user opens the app for the first time, then we want to ignore the network quite preference & sync inbox.
parent 9c80167a
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -531,9 +531,14 @@ public class MessagingController {
        );
    }

    public void synchronizeMailboxBlocking(Account account, String folderServerId) {
    public void synchronizeMailboxBlocking(Account account, String folderServerId, Boolean initialSync) {
        long folderId = getFolderId(account, folderServerId);

        if (!initialSync && K9.INSTANCE.isNetworkQuietTime() && folderId == account.getInboxFolderId()) {
            Timber.i("Network quite time enabled. Skipping sync inbox");
            return;
        }

        final CountDownLatch latch = new CountDownLatch(1);
        putBackground("synchronizeMailbox", null, () -> {
            try {
+4 −4
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ internal class AccountPushController(
    private var backendPusher: BackendPusher? = null

    private val backendPusherCallback = object : BackendPusherCallback {
        override fun onPushEvent(folderServerId: String) {
            syncFolders(folderServerId)
        override fun onPushEvent(folderServerId: String, initialSync: Boolean) {
            syncFolders(folderServerId, initialSync)
        }

        override fun onPushError(exception: Exception) {
@@ -91,8 +91,8 @@ internal class AccountPushController(
        backendPusher?.updateFolders(folderServerIds)
    }

    private fun syncFolders(folderServerId: String) {
        messagingController.synchronizeMailboxBlocking(account, folderServerId)
    private fun syncFolders(folderServerId: String, initialSync: Boolean) {
        messagingController.synchronizeMailboxBlocking(account, folderServerId, initialSync)
    }

    private fun disablePush() {
+1 −1
Original line number Diff line number Diff line
package com.fsck.k9.backend.api

interface BackendPusherCallback {
    fun onPushEvent(folderServerId: String)
    fun onPushEvent(folderServerId: String, initialSync: Boolean = false)
    fun onPushError(exception: Exception)
    fun onPushNotSupported()
}
+2 −2
Original line number Diff line number Diff line
@@ -182,8 +182,8 @@ internal class ImapBackendPusher(
        )
    }

    override fun onPushEvent(folderServerId: String) {
        callback.onPushEvent(folderServerId)
    override fun onPushEvent(folderServerId: String, initialSync: Boolean) {
        callback.onPushEvent(folderServerId, initialSync)
        idleRefreshManager.resetTimers()
    }

+1 −1
Original line number Diff line number Diff line
@@ -96,6 +96,6 @@ class ImapFolderPusher(
    }

    private fun performInitialSync() {
        callback.onPushEvent(folderServerId)
        callback.onPushEvent(folderServerId, true)
    }
}
Loading