account deletion: only attempt to delete omemo id when connected

This commit is contained in:
Daniel Gultsch 2019-09-29 01:40:40 +02:00
parent 7b160a358e
commit 618d892ae7
1 changed files with 16 additions and 11 deletions

View File

@ -2198,19 +2198,24 @@ public class XmppConnectionService extends Service {
} }
public void deleteAccount(final Account account) { public void deleteAccount(final Account account) {
final boolean connected = account.getStatus() == Account.State.ONLINE;
synchronized (this.conversations) { synchronized (this.conversations) {
account.getAxolotlService().deleteOmemoIdentity(); if (connected) {
for (final Conversation conversation : conversations) { account.getAxolotlService().deleteOmemoIdentity();
if (conversation.getAccount() == account) { }
if (conversation.getMode() == Conversation.MODE_MULTI) { for (final Conversation conversation : conversations) {
leaveMuc(conversation); if (conversation.getAccount() == account) {
} if (conversation.getMode() == Conversation.MODE_MULTI) {
conversations.remove(conversation); if (connected) {
mNotificationService.clear(conversation); leaveMuc(conversation);
} }
} }
conversations.remove(conversation);
mNotificationService.clear(conversation);
}
}
if (account.getXmppConnection() != null) { if (account.getXmppConnection() != null) {
new Thread(() -> disconnect(account, false)).start(); new Thread(() -> disconnect(account, !connected)).start();
} }
final Runnable runnable = () -> { final Runnable runnable = () -> {
if (!databaseBackend.deleteAccount(account)) { if (!databaseBackend.deleteAccount(account)) {