Gmail: permanently delete from archive folder

pull/207/head
M66B 3 years ago
parent ed35b644a1
commit c73b490dd7

@ -293,7 +293,8 @@ class Core {
account.protocol == EntityAccount.TYPE_IMAP) {
JSONArray jnext = new JSONArray(next.args);
// Same target
if (jargs.getLong(0) == jnext.getLong(0)) {
if (jargs.getLong(0) == jnext.getLong(0) &&
jargs.optBoolean(4) == jnext.optBoolean(4)) {
EntityMessage m = db.message().getMessage(next.message);
if (m != null && m.uid != null)
similar.put(next, m);
@ -1368,6 +1369,7 @@ class Core {
long id = jargs.getLong(0);
boolean seen = jargs.optBoolean(1);
boolean unflag = jargs.optBoolean(3);
boolean delete = jargs.optBoolean(4);
Flags flags = ifolder.getPermanentFlags();
@ -1507,7 +1509,7 @@ class Core {
}
// Fetch appended/copied when needed
boolean fetch = (copy ||
boolean fetch = (copy || delete ||
!"connected".equals(target.state) ||
!MessageHelper.hasCapability(ifolder, "IDLE"));
if (draft || fetch)
@ -1516,6 +1518,7 @@ class Core {
itarget.open(READ_WRITE);
boolean sync = false;
List<Message> ideletes = new ArrayList<>();
for (EntityMessage message : map.values())
try {
String msgid = msgids.get(message);
@ -1547,7 +1550,12 @@ class Core {
icopy.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(target.type));
}
if (fetch) {
if (delete) {
Log.i(target.name + " Deleting uid=" + uid);
Message idelete = itarget.getMessageByUID(uid);
idelete.setFlag(Flags.Flag.DELETED, true);
ideletes.add(idelete);
} else if (fetch) {
Log.i(target.name + " Fetching uid=" + uid);
JSONArray fargs = new JSONArray();
fargs.put(uid);
@ -1562,6 +1570,8 @@ class Core {
sync = true;
}
expunge(context, itarget, ideletes);
if (sync)
EntityOperation.sync(context, target.id, false);
} catch (Throwable ex) {

@ -187,6 +187,7 @@ public class EntityOperation {
// 1: mark seen
// 2: temporary message
// 3: remove flag
// 4: permanently delete
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean autoread = prefs.getBoolean("autoread", false);
@ -420,6 +421,19 @@ public class EntityOperation {
account.protocol != EntityAccount.TYPE_IMAP) {
message.ui_hide = true;
db.message().setMessageUiHide(message.id, message.ui_hide);
if (perform_expunge && account != null && account.isGmail()) {
EntityFolder source = db.folder().getFolder(message.folder);
if (source != null && EntityFolder.ARCHIVE.equals(source.type)) {
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
if (trash != null && !trash.id.equals(message.folder)) {
jargs.put(0, trash.id); // target
jargs.put(4, true); // delete
queue(context, message.account, message.folder, message.id, EntityOperation.MOVE, jargs);
return;
}
}
}
} else {
message.ui_deleted = !message.ui_deleted;
db.message().setMessageUiDeleted(message.id, message.ui_deleted);

Loading…
Cancel
Save