mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 14:11:00 +00:00
Allow multiple primary accounts
This commit is contained in:
parent
3304732e9e
commit
38d4c4ae88
3 changed files with 20 additions and 8 deletions
|
@ -70,8 +70,8 @@ public interface DaoIdentity {
|
||||||
@Query("UPDATE identity SET error = :error WHERE id = :id")
|
@Query("UPDATE identity SET error = :error WHERE id = :id")
|
||||||
int setIdentityError(long id, String error);
|
int setIdentityError(long id, String error);
|
||||||
|
|
||||||
@Query("UPDATE identity SET `primary` = 0")
|
@Query("UPDATE identity SET `primary` = 0 WHERE account = :account")
|
||||||
void resetPrimary();
|
void resetPrimary(long account);
|
||||||
|
|
||||||
@Query("UPDATE identity SET tbd = 1 WHERE id = :id")
|
@Query("UPDATE identity SET tbd = 1 WHERE id = :id")
|
||||||
int setIdentityTbd(long id);
|
int setIdentityTbd(long id);
|
||||||
|
|
|
@ -1285,7 +1285,9 @@ public class FragmentCompose extends FragmentEx {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select identity matching from address
|
// Select identity matching from address
|
||||||
|
int icount = 0;
|
||||||
String from = null;
|
String from = null;
|
||||||
|
EntityIdentity first = null;
|
||||||
EntityIdentity primary = null;
|
EntityIdentity primary = null;
|
||||||
if (result.draft.from != null && result.draft.from.length > 0)
|
if (result.draft.from != null && result.draft.from.length > 0)
|
||||||
from = Helper.canonicalAddress(((InternetAddress) result.draft.from[0]).getAddress());
|
from = Helper.canonicalAddress(((InternetAddress) result.draft.from[0]).getAddress());
|
||||||
|
@ -1296,14 +1298,24 @@ public class FragmentCompose extends FragmentEx {
|
||||||
result.draft.from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
result.draft.from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (identity.primary)
|
if (identity.account.equals(result.draft.account)) {
|
||||||
primary = identity;
|
icount++;
|
||||||
|
if (identity.primary)
|
||||||
|
primary = identity;
|
||||||
|
if (first == null)
|
||||||
|
first = identity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select primary identity
|
// Select primary identity
|
||||||
if (result.draft.identity == null && primary != null) {
|
if (result.draft.identity == null) {
|
||||||
result.draft.identity = primary.id;
|
if (primary != null) {
|
||||||
result.draft.from = new InternetAddress[]{new InternetAddress(primary.email, primary.name)};
|
result.draft.identity = primary.id;
|
||||||
|
result.draft.from = new InternetAddress[]{new InternetAddress(primary.email, primary.name)};
|
||||||
|
} else if (first != null && icount == 1) {
|
||||||
|
result.draft.identity = first.id;
|
||||||
|
result.draft.from = new InternetAddress[]{new InternetAddress(first.email, first.name)};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.draft.sender = MessageHelper.getSortKey(result.draft.from);
|
result.draft.sender = MessageHelper.getSortKey(result.draft.from);
|
||||||
|
|
|
@ -551,7 +551,7 @@ public class FragmentIdentity extends FragmentEx {
|
||||||
identity.error = null;
|
identity.error = null;
|
||||||
|
|
||||||
if (identity.primary)
|
if (identity.primary)
|
||||||
db.identity().resetPrimary();
|
db.identity().resetPrimary(account);
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
db.identity().updateIdentity(identity);
|
db.identity().updateIdentity(identity);
|
||||||
|
|
Loading…
Reference in a new issue