ensure account also removed from memories on delete

This commit is contained in:
Art O Cathain 2015-03-31 20:10:25 +01:00
parent ffc5ba2cf3
commit 6a03e62f52
2 changed files with 18 additions and 1 deletions

View File

@ -1074,7 +1074,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
// are currently not inserted to be left
}
MessagingController.getInstance(getApplication())
.notifyAccountCancel(Accounts.this, realAccount);
.deleteAccount(Accounts.this, realAccount);
Preferences.getPreferences(Accounts.this)
.deleteAccount(realAccount);
K9.setServicesEnabled(Accounts.this);

View File

@ -5126,6 +5126,11 @@ public class MessagingController implements Runnable {
notificationData.remove(account.getAccountNumber());
}
public void deleteAccount(Context context, Account account) {
notifyAccountCancel(context, account);
memorizingListener.removeAccount(account);
}
/**
* Save a draft message.
* @param account Account we are saving for.
@ -5464,6 +5469,18 @@ public class MessagingController implements Runnable {
return memory;
}
synchronized void removeAccount(Account account) {
Iterator<Entry<String, Memory>> memIt = memories.entrySet().iterator();
while (memIt.hasNext()) {
Entry<String, Memory> memoryEntry = memIt.next();
if (memoryEntry.getValue().account.getUuid().equals(account.getUuid())) {
memIt.remove();
}
}
}
@Override
public synchronized void synchronizeMailboxStarted(Account account, String folder) {
Memory memory = getMemory(account, folder);