diff --git a/app/src/main/java/eu/faircode/email/DaoIdentity.java b/app/src/main/java/eu/faircode/email/DaoIdentity.java index e89d902c1b..78fd044f6b 100644 --- a/app/src/main/java/eu/faircode/email/DaoIdentity.java +++ b/app/src/main/java/eu/faircode/email/DaoIdentity.java @@ -48,6 +48,9 @@ public interface DaoIdentity { @Query("SELECT * FROM identity WHERE id = :id") LiveData liveIdentity(long id); + @Query("SELECT * FROM identity WHERE account = :account AND `primary`") + EntityIdentity getPrimaryIdentity(long account); + @Insert long insertIdentity(EntityIdentity identity); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 810791d0e4..e10f22cc75 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1054,7 +1054,9 @@ public class FragmentCompose extends FragmentEx { EntityOperation.queue(db, draft, EntityOperation.MOVE, trash.id); } else if (action == R.id.action_save) { - if (ato == null && acc == null && abcc == null && + EntityIdentity primary = db.identity().getPrimaryIdentity(draft.account); + if ((primary == null || draft.identity == primary.id) && + ato == null && acc == null && abcc == null && TextUtils.isEmpty(subject) && TextUtils.isEmpty(body) && db.attachment().getAttachmentCount(draft.id) == 0)