Fix assigning account number when Account is first saved (fixes #3787)
This commit is contained in:
parent
05d9315d79
commit
62411ace05
3 changed files with 13 additions and 8 deletions
|
@ -102,6 +102,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||
public static final SortType DEFAULT_SORT_TYPE = SortType.SORT_DATE;
|
||||
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
||||
public static final long NO_OPENPGP_KEY = 0;
|
||||
public static final int UNASSIGNED_ACCOUNT_NUMBER = -1;
|
||||
|
||||
private DeletePolicy deletePolicy = DeletePolicy.NEVER;
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class AccountPreferenceSerializer(
|
|||
|
||||
autoExpandFolder = storage.getString("$accountUuid.autoExpandFolderName", INBOX)
|
||||
|
||||
accountNumber = storage.getInt("$accountUuid.accountNumber", 0)
|
||||
accountNumber = storage.getInt("$accountUuid.accountNumber", UNASSIGNED_ACCOUNT_NUMBER)
|
||||
|
||||
chipColor = storage.getInt("$accountUuid.chipColor", FALLBACK_ACCOUNT_COLOR)
|
||||
|
||||
|
@ -503,7 +503,7 @@ class AccountPreferenceSerializer(
|
|||
idleRefreshMinutes = 24
|
||||
isPushPollOnConnect = true
|
||||
displayCount = K9.DEFAULT_VISIBLE_LIMIT
|
||||
accountNumber = -1
|
||||
accountNumber = UNASSIGNED_ACCOUNT_NUMBER
|
||||
isNotifyNewMail = true
|
||||
folderNotifyNewMailMode = FolderMode.ALL
|
||||
isNotifySync = true
|
||||
|
|
|
@ -203,14 +203,18 @@ public class Preferences {
|
|||
public void saveAccount(Account account) {
|
||||
StorageEditor editor = storage.edit();
|
||||
|
||||
if (!accounts.containsKey(account.getUuid())) {
|
||||
int accountNumber = generateAccountNumber();
|
||||
account.setAccountNumber(accountNumber);
|
||||
ensureAssignedAccountNumber(account);
|
||||
processChangedValues(account);
|
||||
accountPreferenceSerializer.save(storage, editor, account);
|
||||
}
|
||||
|
||||
private void ensureAssignedAccountNumber(Account account) {
|
||||
if (account.getAccountNumber() != Account.UNASSIGNED_ACCOUNT_NUMBER) {
|
||||
return;
|
||||
}
|
||||
|
||||
processChangedValues(account);
|
||||
|
||||
accountPreferenceSerializer.save(storage, editor, account);
|
||||
int accountNumber = generateAccountNumber();
|
||||
account.setAccountNumber(accountNumber);
|
||||
}
|
||||
|
||||
private void processChangedValues(Account account) {
|
||||
|
|
Loading…
Reference in a new issue