mirror of https://github.com/M66B/FairEmail.git
Update folder sync time
This commit is contained in:
parent
01bacf0941
commit
e4ec7e41e3
|
@ -521,7 +521,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||||
db.folder().setFolderError(browsable.id, null);
|
db.folder().setFolderError(browsable.id, null);
|
||||||
|
|
||||||
int count = MessageHelper.getMessageCount(state.ifolder);
|
int count = MessageHelper.getMessageCount(state.ifolder);
|
||||||
db.folder().setFolderTotal(browsable.id, count < 0 ? null : count);
|
db.folder().setFolderTotal(browsable.id, count < 0 ? null : count, new Date().getTime());
|
||||||
|
|
||||||
if (criteria == null) {
|
if (criteria == null) {
|
||||||
boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter(context, "seen", viewType, browsable.type), false);
|
boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter(context, "seen", viewType, browsable.type), false);
|
||||||
|
|
|
@ -1505,7 +1505,7 @@ class Core {
|
||||||
expunge(context, ifolder, deleted);
|
expunge(context, ifolder, deleted);
|
||||||
} else {
|
} else {
|
||||||
int count = MessageHelper.getMessageCount(ifolder);
|
int count = MessageHelper.getMessageCount(ifolder);
|
||||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
db.folder().setFolderTotal(folder.id, count < 0 ? null : count, new Date().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch appended/copied when needed
|
// Fetch appended/copied when needed
|
||||||
|
@ -1703,7 +1703,7 @@ class Core {
|
||||||
db.message().deleteMessage(folder.id, uid);
|
db.message().deleteMessage(folder.id, uid);
|
||||||
} finally {
|
} finally {
|
||||||
int count = MessageHelper.getMessageCount(ifolder);
|
int count = MessageHelper.getMessageCount(ifolder);
|
||||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
db.folder().setFolderTotal(folder.id, count < 0 ? null : count, new Date().getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1814,7 +1814,7 @@ class Core {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
int count = MessageHelper.getMessageCount(ifolder);
|
int count = MessageHelper.getMessageCount(ifolder);
|
||||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
db.folder().setFolderTotal(folder.id, count < 0 ? null : count, new Date().getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,6 +273,11 @@ public interface DaoFolder {
|
||||||
@Query("UPDATE folder SET total = :total WHERE id = :id AND NOT (total IS :total)")
|
@Query("UPDATE folder SET total = :total WHERE id = :id AND NOT (total IS :total)")
|
||||||
int setFolderTotal(long id, Integer total);
|
int setFolderTotal(long id, Integer total);
|
||||||
|
|
||||||
|
@Query("UPDATE folder SET total = :total, last_sync = :last_sync" +
|
||||||
|
" WHERE id = :id" +
|
||||||
|
" AND NOT (total IS :total AND last_sync IS :last_sync)")
|
||||||
|
int setFolderTotal(long id, Integer total, Long last_sync);
|
||||||
|
|
||||||
@Query("UPDATE folder SET error = :error WHERE id = :id AND NOT (error IS :error)")
|
@Query("UPDATE folder SET error = :error WHERE id = :id AND NOT (error IS :error)")
|
||||||
int setFolderError(long id, String error);
|
int setFolderError(long id, String error);
|
||||||
|
|
||||||
|
|
|
@ -372,6 +372,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
private Boolean lastRefreshing;
|
private Boolean lastRefreshing;
|
||||||
private Boolean lastFolderErrors;
|
private Boolean lastFolderErrors;
|
||||||
private Boolean lastAccountErrors;
|
private Boolean lastAccountErrors;
|
||||||
|
private Long lastSyncTime;
|
||||||
|
|
||||||
final private Map<String, String> kv = new HashMap<>();
|
final private Map<String, String> kv = new HashMap<>();
|
||||||
final private Map<String, List<Long>> values = new HashMap<>();
|
final private Map<String, List<Long>> values = new HashMap<>();
|
||||||
|
@ -5703,10 +5704,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long syncTime = null;
|
||||||
|
if (viewType == AdapterMessage.ViewType.FOLDER && folders.size() == 1)
|
||||||
|
syncTime = folders.get(0).last_sync;
|
||||||
|
|
||||||
if (Objects.equals(lastUnseen, unseen) &&
|
if (Objects.equals(lastUnseen, unseen) &&
|
||||||
Objects.equals(lastRefreshing, refreshing) &&
|
Objects.equals(lastRefreshing, refreshing) &&
|
||||||
Objects.equals(lastFolderErrors, folderErrors) &&
|
Objects.equals(lastFolderErrors, folderErrors) &&
|
||||||
Objects.equals(lastAccountErrors, accountErrors)) {
|
Objects.equals(lastAccountErrors, accountErrors) &&
|
||||||
|
Objects.equals(lastSyncTime, syncTime)) {
|
||||||
Log.i("Folder state unchanged");
|
Log.i("Folder state unchanged");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5715,6 +5721,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
lastRefreshing = refreshing;
|
lastRefreshing = refreshing;
|
||||||
lastFolderErrors = folderErrors;
|
lastFolderErrors = folderErrors;
|
||||||
lastAccountErrors = accountErrors;
|
lastAccountErrors = accountErrors;
|
||||||
|
lastSyncTime = syncTime;
|
||||||
|
|
||||||
// Get name
|
// Get name
|
||||||
String name;
|
String name;
|
||||||
|
@ -5740,14 +5747,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
name = getString(R.string.title_name_count, name, NF.format(unseen));
|
name = getString(R.string.title_name_count, name, NF.format(unseen));
|
||||||
setSubtitle(name);
|
setSubtitle(name);
|
||||||
|
|
||||||
if (viewType == AdapterMessage.ViewType.FOLDER &&
|
tvLastSync.setText(syncTime == null ? null
|
||||||
folders.size() == 1 &&
|
: DateUtils.getRelativeTimeSpanString(context, syncTime, true));
|
||||||
folders.get(0).last_sync != null) {
|
grpLastSync.setVisibility(syncTime == null ? View.GONE : View.VISIBLE);
|
||||||
tvLastSync.setText(DateUtils.getRelativeTimeSpanString(context,
|
|
||||||
folders.get(0).last_sync, true));
|
|
||||||
grpLastSync.setVisibility(View.VISIBLE);
|
|
||||||
} else
|
|
||||||
grpLastSync.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
fabError.setTag(accountErrors);
|
fabError.setTag(accountErrors);
|
||||||
if (folderErrors || accountErrors)
|
if (folderErrors || accountErrors)
|
||||||
|
|
Loading…
Reference in New Issue