Update unique accounts only

This commit is contained in:
M66B 2021-10-06 10:44:16 +02:00
parent b6a4704383
commit 8c993e9b02
3 changed files with 15 additions and 5 deletions

View File

@ -151,7 +151,7 @@ public interface DaoAccount {
@Query("SELECT * FROM account" +
" WHERE user = :user" +
" AND auth_type = :auth_type")
EntityAccount getAccount(String user, int auth_type);
List<EntityAccount> getAccounts(String user, int auth_type);
@Query("SELECT * FROM account WHERE `primary`")
EntityAccount getPrimaryAccount();

View File

@ -451,8 +451,13 @@ public class FragmentGmail extends FragmentBase {
try {
db.beginTransaction();
if (args.getBoolean("update"))
update = db.account().getAccount(user, AUTH_TYPE_GMAIL);
if (args.getBoolean("update")) {
List<EntityAccount> accounts =
db.account().getAccounts(user, AUTH_TYPE_GMAIL);
if (accounts != null && accounts.size() == 1)
update = accounts.get(0);
}
if (update == null) {
EntityAccount primary = db.account().getPrimaryAccount();

View File

@ -770,8 +770,13 @@ public class FragmentOAuth extends FragmentBase {
try {
db.beginTransaction();
if (args.getBoolean("update"))
update = db.account().getAccount(username, AUTH_TYPE_OAUTH);
if (args.getBoolean("update")) {
List<EntityAccount> accounts =
db.account().getAccounts(username, AUTH_TYPE_OAUTH);
if (accounts != null && accounts.size() == 1)
update = accounts.get(0);
}
if (update == null) {
EntityAccount primary = db.account().getPrimaryAccount();