1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 11:15:51 +00:00

Refactoring

This commit is contained in:
M66B 2020-04-14 15:29:01 +02:00
parent 94f6e850e3
commit 6395d92bfd
3 changed files with 23 additions and 10 deletions

View file

@ -4825,7 +4825,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
if (!Objects.equals(prev.last_attempt, next.last_attempt)) {
same = false;
log("last_attempt changed " + prev.ui_busy + "/" + next.ui_busy, next.id);
log("last_attempt changed " +
(prev.last_attempt % 10000) + "/" + (next.last_attempt % 10000), next.id);
}
// accountPop

View file

@ -559,8 +559,8 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id")
int setMessageUiIgnored(long id, boolean ui_ignored);
@Query("UPDATE message SET ui_busy = :busy, last_attempt = :now WHERE id = :id")
int setMessageUiBusy(long id, Long busy, long now);
@Query("UPDATE message SET ui_busy = :busy WHERE id = :id")
int setMessageUiBusy(long id, Long busy);
@Query("UPDATE message SET received = :sent, sent = :sent WHERE id = :id")
int setMessageSent(long id, Long sent);

View file

@ -4429,13 +4429,23 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
DB db = DB.getInstance(context);
long now = new Date().getTime();
long busy = now + UNDO_TIMEOUT * 2;
for (MessageTarget target : result) {
db.message().setMessageUiBusy(target.id, busy, now);
db.message().setMessageUiHide(target.id, true);
// Prevent new message notification on undo
db.message().setMessageUiIgnored(target.id, true);
try {
db.beginTransaction();
for (MessageTarget target : result) {
db.message().setMessageUiBusy(target.id, busy);
db.message().setMessageUiHide(target.id, true);
// Prevent new message notification on undo
db.message().setMessageUiIgnored(target.id, true);
db.message().setMessageLastAttempt(target.id, now);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return result;
@ -4469,8 +4479,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
for (MessageTarget target : result) {
Log.i("Move undo id=" + target.id);
db.message().setMessageUiBusy(target.id, null, new Date().getTime());
db.message().setMessageUiBusy(target.id, null);
db.message().setMessageUiHide(target.id, false);
db.message().setMessageLastAttempt(target.id, new Date().getTime());
}
db.setTransactionSuccessful();
@ -4518,7 +4529,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
continue;
Log.i("Move id=" + id + " target=" + target.folder.name);
db.message().setMessageUiBusy(target.id, null, new Date().getTime());
db.message().setMessageUiBusy(target.id, null);
db.message().setMessageLastAttempt(target.id, new Date().getTime());
EntityOperation.queue(context, message, EntityOperation.MOVE, target.folder.id);
}