diff --git a/app/src/main/java/eu/faircode/email/DaoAccount.java b/app/src/main/java/eu/faircode/email/DaoAccount.java index 746a1223bf..637572acc1 100644 --- a/app/src/main/java/eu/faircode/email/DaoAccount.java +++ b/app/src/main/java/eu/faircode/email/DaoAccount.java @@ -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 getAccounts(String user, int auth_type); @Query("SELECT * FROM account WHERE `primary`") EntityAccount getPrimaryAccount(); diff --git a/app/src/main/java/eu/faircode/email/FragmentGmail.java b/app/src/main/java/eu/faircode/email/FragmentGmail.java index be117690af..d0c2248bd7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentGmail.java +++ b/app/src/main/java/eu/faircode/email/FragmentGmail.java @@ -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 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(); diff --git a/app/src/main/java/eu/faircode/email/FragmentOAuth.java b/app/src/main/java/eu/faircode/email/FragmentOAuth.java index 2d2a7a9c14..643924c173 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOAuth.java +++ b/app/src/main/java/eu/faircode/email/FragmentOAuth.java @@ -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 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();