mirror of https://github.com/M66B/FairEmail.git
Allow undoing delete
This commit is contained in:
parent
54d806d3ed
commit
59f09ce624
|
@ -1330,7 +1330,7 @@ class Core {
|
|||
}
|
||||
|
||||
try {
|
||||
boolean deleted = false;
|
||||
boolean found = false;
|
||||
|
||||
if (message.uid != null) {
|
||||
Message iexisting = ifolder.getMessageByUID(message.uid);
|
||||
|
@ -1339,14 +1339,17 @@ class Core {
|
|||
else
|
||||
try {
|
||||
Log.i(folder.name + " deleting uid=" + message.uid);
|
||||
iexisting.setFlag(Flags.Flag.DELETED, true);
|
||||
deleted = true;
|
||||
if (perform_expunge)
|
||||
iexisting.setFlag(Flags.Flag.DELETED, true);
|
||||
else
|
||||
iexisting.setFlag(Flags.Flag.DELETED, message.ui_deleted);
|
||||
found = true;
|
||||
} catch (MessageRemovedException ignored) {
|
||||
Log.w(folder.name + " existing gone uid=" + message.uid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(message.msgid) && !deleted)
|
||||
if (!found && !TextUtils.isEmpty(message.msgid))
|
||||
try {
|
||||
Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid));
|
||||
if (imessages == null)
|
||||
|
@ -1356,8 +1359,11 @@ class Core {
|
|||
long muid = ifolder.getUID(iexisting);
|
||||
Log.i(folder.name + " deleting uid=" + muid);
|
||||
try {
|
||||
iexisting.setFlag(Flags.Flag.DELETED, true);
|
||||
deleted = true;
|
||||
if (perform_expunge)
|
||||
iexisting.setFlag(Flags.Flag.DELETED, true);
|
||||
else
|
||||
iexisting.setFlag(Flags.Flag.DELETED, message.ui_deleted);
|
||||
found = true;
|
||||
} catch (MessageRemovedException ignored) {
|
||||
Log.w(folder.name + " existing gone uid=" + muid);
|
||||
}
|
||||
|
@ -1367,10 +1373,14 @@ class Core {
|
|||
}
|
||||
|
||||
if (perform_expunge) {
|
||||
if (deleted)
|
||||
if (found)
|
||||
ifolder.expunge(); // NO EXPUNGE failed.
|
||||
db.message().deleteMessage(message.id);
|
||||
} else {
|
||||
if (found)
|
||||
db.message().setMessageDeleted(message.id, message.ui_deleted);
|
||||
}
|
||||
|
||||
} finally {
|
||||
int count = MessageHelper.getMessageCount(ifolder);
|
||||
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
|
||||
|
|
|
@ -628,6 +628,9 @@ public interface DaoMessage {
|
|||
@Query("UPDATE message SET flagged = :flagged WHERE id = :id AND NOT (flagged IS :flagged)")
|
||||
int setMessageFlagged(long id, boolean flagged);
|
||||
|
||||
@Query("UPDATE message SET deleted = :deleted WHERE id = :id AND NOT (deleted IS :deleted)")
|
||||
int setMessageDeleted(long id, boolean deleted);
|
||||
|
||||
@Query("UPDATE message SET answered = :answered WHERE id = :id AND NOT (answered IS :answered)")
|
||||
int setMessageAnswered(long id, boolean answered);
|
||||
|
||||
|
|
|
@ -346,8 +346,10 @@ public class EntityOperation {
|
|||
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
|
||||
if (perform_expunge)
|
||||
db.message().setMessageUiHide(message.id, true);
|
||||
else
|
||||
db.message().setMessageUiDeleted(message.id, true);
|
||||
else {
|
||||
message.ui_deleted = !message.ui_deleted;
|
||||
db.message().setMessageUiDeleted(message.id, message.ui_deleted);
|
||||
}
|
||||
/*
|
||||
if (message.hash != null) {
|
||||
List<EntityMessage> sames = db.message().getMessagesByHash(message.account, message.hash);
|
||||
|
|
Loading…
Reference in New Issue