Check if can archive on send

This commit is contained in:
M66B 2021-02-01 12:39:42 +01:00
parent c7040d1af1
commit 07f587b535
1 changed files with 26 additions and 1 deletions

View File

@ -5984,6 +5984,7 @@ public class FragmentCompose extends FragmentBase {
if (archive == null) {
Bundle args = new Bundle();
args.putLong("account", draft.account);
args.putString("inreplyto", draft.inreplyto);
new SimpleTask<Boolean>() {
@Override
@ -5994,6 +5995,30 @@ public class FragmentCompose extends FragmentBase {
@Override
protected Boolean onExecute(Context context, Bundle args) {
long account = args.getLong("account");
String inreplyto = args.getString("inreplyto");
if (TextUtils.isEmpty(inreplyto))
return null;
List<EntityMessage> messages = db.message().getMessagesByMsgId(account, inreplyto);
if (messages == null)
return null;
boolean canArchive = false;
for (EntityMessage message : messages) {
EntityFolder folder = db.folder().getFolder(message.folder);
if (folder == null)
continue;
if (EntityFolder.INBOX.equals(folder.type) ||
EntityFolder.SYSTEM.equals(folder.type) ||
EntityFolder.USER.equals(folder.type)) {
canArchive = true;
break;
}
}
if (!canArchive)
return null;
DB db = DB.getInstance(context);
EntityFolder archive = db.folder().getFolderByType(account, EntityFolder.ARCHIVE);
@ -6004,7 +6029,7 @@ public class FragmentCompose extends FragmentBase {
@Override
protected void onExecuted(Bundle args, Boolean data) {
archive = data;
cbArchive.setChecked(send_archive);
cbArchive.setChecked(send_archive && archive);
cbArchive.setVisibility(archive ? View.VISIBLE : View.GONE);
}