Select identity for external drafts

pull/184/head
M66B 4 years ago
parent aea8e76c92
commit d497aa4e02

@ -2920,6 +2920,9 @@ class Core {
private static EntityIdentity matchIdentity(Context context, EntityFolder folder, EntityMessage message) {
DB db = DB.getInstance(context);
if (EntityFolder.DRAFTS.equals(folder.type))
return null;
List<Address> addresses = new ArrayList<>();
if (folder.isOutgoing()) {
if (message.from != null)

@ -664,6 +664,9 @@ public interface DaoMessage {
@Query("UPDATE message SET error = :error WHERE id = :id")
int setMessageError(long id, String error);
@Query("UPDATE message SET identity = :identity WHERE id = :id")
int setMessageIdentity(long id, Long identity);
@Query("UPDATE message SET revision = :revision WHERE id = :id")
int setMessageRevision(long id, Integer revision);

@ -3720,6 +3720,21 @@ public class FragmentCompose extends FragmentBase {
} else {
args.putBoolean("saved", true);
// External draft
if (data.draft.identity == null) {
for (EntityIdentity identity : data.identities)
if (identity.account.equals(data.draft.account))
if (identity.primary) {
data.draft.identity = identity.id;
break;
} else if (data.draft.identity == null)
data.draft.identity = identity.id;
if (data.draft.identity != null)
db.message().setMessageIdentity(data.draft.id, data.draft.identity);
Log.i("Selected external identity=" + data.draft.identity);
}
if (data.draft.revision == null) {
data.draft.revision = 1;
data.draft.revisions = 1;

Loading…
Cancel
Save