Remove "otherJid" when receiving unavailable presence.

This commit is contained in:
chteufleur 2018-10-05 19:34:16 +02:00
parent ebe4208502
commit 27f506c253
1 changed files with 20 additions and 14 deletions

View File

@ -172,10 +172,11 @@ public class ServiceXmpp extends Observable implements PresenceEventListener {
}
@Override
public void presenceAvailable(FullJid address, Presence availablePresence) {
public void presenceAvailable(FullJid address, Presence presence) {
String fullJid = address.asFullJidIfPossible().toString();
if (presence.getType() == Presence.Type.available) {
if (!fullJid.equals(jid) && (otherJid == null || !fullJid.equals(otherJid))) {
Log.i(TAG, "PRESENCE AVAILABLE RECEIVED FROM "+fullJid);
Log.i(TAG, "PRESENCE AVAILABLE RECEIVED FROM " + fullJid);
otherJid = fullJid;
try {
sendPresenceAvailable(fullJid);
@ -189,6 +190,11 @@ public class ServiceXmpp extends Observable implements PresenceEventListener {
setChanged();
notifyObservers(new Notification(NOTIF_NEW_PRESENCE_RECEIVED).addExtra(NOTIF_NEW_PRESENCE_RECEIVED_VALUE_JID, otherJid));
}
} else if (presence.getType() == Presence.Type.unavailable) {
if (otherJid != null && otherJid.equals(fullJid)) {
otherJid = null;
}
}
}
@Override