Better target folder evaluation

pull/147/head
M66B 6 years ago
parent 5c9706e912
commit aaafa4275a

@ -788,23 +788,32 @@ public class FragmentMessages extends FragmentBase {
private void onMore() { private void onMore() {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("folder", folder);
args.putLongArray("ids", getSelection()); args.putLongArray("ids", getSelection());
new SimpleTask<MoreResult>() { new SimpleTask<MoreResult>() {
@Override @Override
protected MoreResult onExecute(Context context, Bundle args) { protected MoreResult onExecute(Context context, Bundle args) {
long fid = args.getLong("folder");
long[] ids = args.getLongArray("ids"); long[] ids = args.getLongArray("ids");
MoreResult result = new MoreResult(); MoreResult result = new MoreResult();
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
List<Long> fids = new ArrayList<>();
for (long id : ids) { for (long id : ids) {
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
if (message != null) { if (message == null)
continue;
if (!fids.contains(message.folder))
fids.add(message.folder);
EntityFolder folder = db.folder().getFolder(message.folder);
result.isArchive = EntityFolder.ARCHIVE.equals(folder.type);
result.isTrash = EntityFolder.TRASH.equals(folder.type);
result.isJunk = EntityFolder.JUNK.equals(folder.type);
result.isDrafts = EntityFolder.DRAFTS.equals(folder.type);
if (message.ui_seen) if (message.ui_seen)
result.seen = true; result.seen = true;
else else
@ -822,15 +831,6 @@ public class FragmentMessages extends FragmentBase {
result.hasJunk = (result.hasJunk && result.hasJunk = (result.hasJunk &&
db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null); db.folder().getFolderByType(message.account, EntityFolder.JUNK) != null);
} }
}
EntityFolder folder = db.folder().getFolder(fid);
if (folder != null) {
result.isArchive = EntityFolder.ARCHIVE.equals(folder.type);
result.isTrash = EntityFolder.TRASH.equals(folder.type);
result.isJunk = EntityFolder.JUNK.equals(folder.type);
result.isDrafts = EntityFolder.DRAFTS.equals(folder.type);
}
result.accounts = db.account().getAccounts(true); result.accounts = db.account().getAccounts(true);
@ -854,7 +854,7 @@ public class FragmentMessages extends FragmentBase {
!EntityFolder.ARCHIVE.equals(target.type) && !EntityFolder.ARCHIVE.equals(target.type) &&
!EntityFolder.TRASH.equals(target.type) && !EntityFolder.TRASH.equals(target.type) &&
!EntityFolder.JUNK.equals(target.type) && !EntityFolder.JUNK.equals(target.type) &&
!target.id.equals(fid)) (fids.size() != 1 || !fids.contains(target.id)))
targets.add(target); targets.add(target);
EntityFolder.sort(context, targets); EntityFolder.sort(context, targets);
result.targets.put(account, targets); result.targets.put(account, targets);

Loading…
Cancel
Save