Skip to content

Commit

Permalink
Try to fix bug: when deleting contact, chat of this contact stay in m…
Browse files Browse the repository at this point in the history
…emory
  • Loading branch information
Str4tocaster committed Jul 12, 2017
1 parent 79b4a9d commit 1f4bfcc
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.entity.AccountJid;
import com.xabber.android.data.entity.UserJid;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.RosterManager;
Expand Down Expand Up @@ -56,11 +57,18 @@ public void onClick(DialogInterface dialog, int which) {
MessageManager.getInstance().closeChat(account, user);

try {
// discard subscription
PresenceManager.getInstance().discardSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(R.string.CONNECTION_FAILED);
}

// delete chat
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat != null)
MessageManager.getInstance().removeChat(chat);

// remove roster contact
RosterManager.getInstance().removeContact(account, user);

if (getActivity() instanceof ContactActivity) {
Expand Down

0 comments on commit 1f4bfcc

Please sign in to comment.