diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index fdf322c5fb..33c347154f 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -263,7 +263,7 @@ public class AdapterMessage extends PagedListAdapter() { @Override protected String[] onLoad(Context context, Bundle args) { long id = args.getLong("id"); int direction = args.getInt("direction"); + boolean single = args.getBoolean("single"); EntityFolder target = null; // Get target folder and hide message @@ -266,7 +269,14 @@ public class FragmentMessages extends FragmentEx { target = db.folder().getFolderByType(message.account, EntityFolder.TRASH); } - db.message().setMessageUiHide(message.id, true); + List messages = new ArrayList<>(); + if (single) + messages.add(message); + else + messages.addAll(db.message().getMessageByThread(message.account, message.thread)); + + for (EntityMessage m : messages) + db.message().setMessageUiHide(m.id, true); db.setTransactionSuccessful(); } finally { @@ -295,8 +305,30 @@ public class FragmentMessages extends FragmentEx { @Override protected Void onLoad(Context context, Bundle args) { long id = args.getLong("id"); - Log.i(Helper.TAG, "Undo move id=" + id); - DB.getInstance(context).message().setMessageUiHide(id, false); + boolean single = args.getBoolean("single"); + + DB db = DB.getInstance(context); + try { + db.beginTransaction(); + + EntityMessage message = db.message().getMessage(id); + + List messages = new ArrayList<>(); + if (single) + messages.add(message); + else + messages.addAll(db.message().getMessageByThread(message.account, message.thread)); + + for (EntityMessage m : messages) { + Log.i(Helper.TAG, "Undo move id=" + m.id); + DB.getInstance(context).message().setMessageUiHide(m.id, false); + } + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + return null; }