Fixed enabling junk filter for non inbox folders

pull/199/head
M66B 4 years ago
parent 24d74fb0ac
commit bba731e1e5

@ -162,33 +162,36 @@ public class FragmentDialogJunk extends FragmentDialogBase {
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
protected Void onExecute(Context context, Bundle args) throws Throwable { protected Void onExecute(Context context, Bundle args) throws Throwable {
long account = args.getLong("account"); long aid = args.getLong("account");
long fid = args.getLong("folder");
boolean filter = args.getBoolean("filter"); boolean filter = args.getBoolean("filter");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); EntityFolder folder = db.folder().getFolder(fid);
if (inbox == null) if (folder == null)
return null; return null;
EntityFolder junk = db.folder().getFolderByType(account, EntityFolder.JUNK); EntityFolder junk = db.folder().getFolderByType(aid, EntityFolder.JUNK);
if (junk == null) if (junk == null)
return null; return null;
try { try {
db.beginTransaction(); db.beginTransaction();
db.folder().setFolderDownload( db.folder().setFolderDownload(folder.id,
inbox.id, inbox.download || filter); folder.download || filter);
db.folder().setFolderAutoClassify( db.folder().setFolderAutoClassify(folder.id,
inbox.id, inbox.auto_classify_source || filter, inbox.auto_classify_target); folder.auto_classify_source || filter,
folder.auto_classify_target);
db.folder().setFolderDownload( db.folder().setFolderDownload(junk.id,
junk.id, junk.download || filter); junk.download || filter);
db.folder().setFolderAutoClassify( db.folder().setFolderAutoClassify(junk.id,
junk.id, junk.auto_classify_source || filter, filter); junk.auto_classify_source || filter,
filter);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
@ -251,22 +254,23 @@ public class FragmentDialogJunk extends FragmentDialogBase {
@Override @Override
protected Boolean onExecute(Context context, Bundle args) throws Throwable { protected Boolean onExecute(Context context, Bundle args) throws Throwable {
long account = args.getLong("account"); long aid = args.getLong("account");
long fid = args.getLong("folder");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean classification = prefs.getBoolean("classification", false); boolean classification = prefs.getBoolean("classification", false);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); EntityFolder folder = db.folder().getFolder(fid);
if (inbox == null) if (folder == null)
return false; return null;
EntityFolder junk = db.folder().getFolderByType(account, EntityFolder.JUNK); EntityFolder junk = db.folder().getFolderByType(aid, EntityFolder.JUNK);
if (junk == null) if (junk == null)
return false; return null;
return (classification && return (classification &&
inbox.download && inbox.auto_classify_source && folder.download && folder.auto_classify_source &&
junk.download && junk.auto_classify_source && junk.auto_classify_target); junk.download && junk.auto_classify_source && junk.auto_classify_target);
} }

Loading…
Cancel
Save