mirror of https://github.com/M66B/FairEmail.git
Observe new folders
This commit is contained in:
parent
dea368dd96
commit
11d8272633
|
@ -187,6 +187,9 @@ public interface DaoFolder {
|
|||
@Query("UPDATE folder SET state = :state WHERE id = :id")
|
||||
int setFolderState(long id, String state);
|
||||
|
||||
@Query("UPDATE folder SET state = :state WHERE account = :account")
|
||||
int setFolderStates(long account, String state);
|
||||
|
||||
@Query("UPDATE folder SET sync_state = :state WHERE id = :id")
|
||||
int setFolderSyncState(long id, String state);
|
||||
|
||||
|
|
|
@ -682,24 +682,10 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
}
|
||||
});
|
||||
|
||||
List<EntityFolder> folders = db.folder().getFolders(account.id);
|
||||
Collections.sort(folders, new Comparator<EntityFolder>() {
|
||||
@Override
|
||||
public int compare(EntityFolder f1, EntityFolder f2) {
|
||||
int s1 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type);
|
||||
int s2 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type);
|
||||
int s = Integer.compare(s1, s2);
|
||||
if (s != 0)
|
||||
return s;
|
||||
|
||||
return f1.name.compareTo(f2.name);
|
||||
}
|
||||
});
|
||||
|
||||
// Initiate connection
|
||||
EntityLog.log(this, account.name + " connecting");
|
||||
for (EntityFolder folder : folders)
|
||||
db.folder().setFolderState(folder.id, null);
|
||||
db.folder().setFolderStates(account.id, null);
|
||||
db.account().setAccountState(account.id, "connecting");
|
||||
|
||||
try {
|
||||
|
@ -747,6 +733,21 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
|
||||
// Open synchronizing folders
|
||||
final ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
|
||||
|
||||
List<EntityFolder> folders = db.folder().getFolders(account.id);
|
||||
Collections.sort(folders, new Comparator<EntityFolder>() {
|
||||
@Override
|
||||
public int compare(EntityFolder f1, EntityFolder f2) {
|
||||
int s1 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type);
|
||||
int s2 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type);
|
||||
int s = Integer.compare(s1, s2);
|
||||
if (s != 0)
|
||||
return s;
|
||||
|
||||
return f1.name.compareTo(f2.name);
|
||||
}
|
||||
});
|
||||
|
||||
for (final EntityFolder folder : folders) {
|
||||
if (folder.synchronize && !folder.poll && capIdle) {
|
||||
Log.i(account.name + " sync folder " + folder.name);
|
||||
|
@ -957,6 +958,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
} else
|
||||
mapFolders.put(folder, null);
|
||||
|
||||
Log.i(folder.name + " observing");
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in New Issue