1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 12:44:42 +00:00

Fallback to primary drafts folder

This commit is contained in:
M66B 2019-02-28 07:05:23 +00:00
parent 889450d5af
commit fd9a27f4cd

View file

@ -1483,7 +1483,7 @@ public class FragmentCompose extends FragmentBase {
if (draft == null || draft.ui_hide) { if (draft == null || draft.ui_hide) {
// New draft // New draft
if ("edit".equals(action)) if ("edit".equals(action))
throw new IllegalArgumentException("Draft not found hide=" + (draft != null)); throw new IllegalStateException("Draft not found hide=" + (draft != null));
List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null); List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null);
@ -1491,13 +1491,19 @@ public class FragmentCompose extends FragmentBase {
EntityMessage ref = db.message().getMessage(reference); EntityMessage ref = db.message().getMessage(reference);
if (ref == null) { if (ref == null) {
long aid = args.getLong("account", -1); long aid = args.getLong("account", -1);
drafts = (aid < 0 if (aid < 0)
? db.folder().getPrimaryDrafts() drafts = db.folder().getPrimaryDrafts();
: db.folder().getFolderByType(aid, EntityFolder.DRAFTS)); else {
drafts = db.folder().getFolderByType(aid, EntityFolder.DRAFTS);
if (drafts == null)
drafts = db.folder().getPrimaryDrafts();
}
if (drafts == null) if (drafts == null)
throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts)); throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts));
} else { } else {
drafts = db.folder().getFolderByType(ref.account, EntityFolder.DRAFTS); drafts = db.folder().getFolderByType(ref.account, EntityFolder.DRAFTS);
if (drafts == null)
drafts = db.folder().getPrimaryDrafts();
if (drafts == null) if (drafts == null)
throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts)); throw new IllegalArgumentException(context.getString(R.string.title_no_primary_drafts));
@ -1703,7 +1709,7 @@ public class FragmentCompose extends FragmentBase {
} else { } else {
if (!draft.content) { if (!draft.content) {
if (draft.uid == null) if (draft.uid == null)
throw new IllegalArgumentException("Draft without uid"); throw new IllegalStateException("Draft without uid");
EntityOperation.queue(context, db, draft, EntityOperation.BODY); EntityOperation.queue(context, db, draft, EntityOperation.BODY);
} }
@ -1857,6 +1863,8 @@ public class FragmentCompose extends FragmentBase {
// External app sending absolute file // External app sending absolute file
if (ex instanceof SecurityException) if (ex instanceof SecurityException)
handleFileShare(); handleFileShare();
else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.toString(), Snackbar.LENGTH_LONG).show();
else else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex); Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} }