Update folder sync time

This commit is contained in:
M66B 2022-05-02 15:23:16 +02:00
parent 01bacf0941
commit e4ec7e41e3
4 changed files with 20 additions and 13 deletions

View File

@ -521,7 +521,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
db.folder().setFolderError(browsable.id, null);
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) {
boolean filter_seen = prefs.getBoolean(FragmentMessages.getFilter(context, "seen", viewType, browsable.type), false);

View File

@ -1505,7 +1505,7 @@ class Core {
expunge(context, ifolder, deleted);
} else {
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
@ -1703,7 +1703,7 @@ class Core {
db.message().deleteMessage(folder.id, uid);
} finally {
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 {
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());
}
}

View File

@ -273,6 +273,11 @@ public interface DaoFolder {
@Query("UPDATE folder SET total = :total WHERE id = :id AND NOT (total IS :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)")
int setFolderError(long id, String error);

View File

@ -372,6 +372,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private Boolean lastRefreshing;
private Boolean lastFolderErrors;
private Boolean lastAccountErrors;
private Long lastSyncTime;
final private Map<String, String> kv = 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) &&
Objects.equals(lastRefreshing, refreshing) &&
Objects.equals(lastFolderErrors, folderErrors) &&
Objects.equals(lastAccountErrors, accountErrors)) {
Objects.equals(lastAccountErrors, accountErrors) &&
Objects.equals(lastSyncTime, syncTime)) {
Log.i("Folder state unchanged");
return;
}
@ -5715,6 +5721,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
lastRefreshing = refreshing;
lastFolderErrors = folderErrors;
lastAccountErrors = accountErrors;
lastSyncTime = syncTime;
// Get 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));
setSubtitle(name);
if (viewType == AdapterMessage.ViewType.FOLDER &&
folders.size() == 1 &&
folders.get(0).last_sync != null) {
tvLastSync.setText(DateUtils.getRelativeTimeSpanString(context,
folders.get(0).last_sync, true));
grpLastSync.setVisibility(View.VISIBLE);
} else
grpLastSync.setVisibility(View.GONE);
tvLastSync.setText(syncTime == null ? null
: DateUtils.getRelativeTimeSpanString(context, syncTime, true));
grpLastSync.setVisibility(syncTime == null ? View.GONE : View.VISIBLE);
fabError.setTag(accountErrors);
if (folderErrors || accountErrors)