diff --git a/app/src/main/java/eu/faircode/email/DaoAccount.java b/app/src/main/java/eu/faircode/email/DaoAccount.java index f558c96ac4..11088c4966 100644 --- a/app/src/main/java/eu/faircode/email/DaoAccount.java +++ b/app/src/main/java/eu/faircode/email/DaoAccount.java @@ -37,6 +37,13 @@ public interface DaoAccount { " ORDER BY `order`, `primary` DESC, name COLLATE NOCASE") List getSynchronizingAccounts(); + @Query("SELECT * FROM account" + + " WHERE (:id IS NULL OR id = :id)" + + " AND synchronize" + + " AND NOT ondemand" + + " ORDER BY `order`, `primary` DESC, name COLLATE NOCASE") + List getPollAccounts(Long id); + @Query("SELECT * FROM account WHERE synchronize") LiveData> liveSynchronizingAccounts(); diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index ab03e5e99c..a57c84e48b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -445,15 +445,14 @@ public class ServiceUI extends IntentService { try { db.beginTransaction(); - List accounts = db.account().getSynchronizingAccounts(); - for (EntityAccount account : accounts) - if (aid < 0 || account.id.equals(aid)) { - List folders = db.folder().getSynchronizingFolders(account.id); - if (folders.size() > 0) - Collections.sort(folders, folders.get(0).getComparator(this)); - for (EntityFolder folder : folders) - EntityOperation.sync(this, folder.id, false); - } + List accounts = db.account().getPollAccounts(aid < 0 ? null : aid); + for (EntityAccount account : accounts) { + List folders = db.folder().getSynchronizingFolders(account.id); + if (folders.size() > 0) + Collections.sort(folders, folders.get(0).getComparator(this)); + for (EntityFolder folder : folders) + EntityOperation.sync(this, folder.id, false); + } db.setTransactionSuccessful(); } finally {