mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 07:22:07 +01:00
muc: only call userHasLeft() at one site
There is no need to duplicate that code. Also ensure that userHasLeft() is invoked *before* the listeners are invoked, so that e.g. isJoined() returns false in the listeners.
This commit is contained in:
parent
ab2822be3e
commit
26ab832452
1 changed files with 3 additions and 20 deletions
|
@ -233,6 +233,9 @@ public class MultiUserChat {
|
||||||
occupantsMap.remove(from);
|
occupantsMap.remove(from);
|
||||||
MUCUser mucUser = MUCUser.from(packet);
|
MUCUser mucUser = MUCUser.from(packet);
|
||||||
if (mucUser != null && mucUser.hasStatus()) {
|
if (mucUser != null && mucUser.hasStatus()) {
|
||||||
|
if (isUserStatusModification) {
|
||||||
|
userHasLeft();
|
||||||
|
}
|
||||||
// Fire events according to the received presence code
|
// Fire events according to the received presence code
|
||||||
checkPresenceCode(
|
checkPresenceCode(
|
||||||
mucUser.getStatus(),
|
mucUser.getStatus(),
|
||||||
|
@ -2438,9 +2441,6 @@ public class MultiUserChat {
|
||||||
if (statusCodes.contains(Status.KICKED_307)) {
|
if (statusCodes.contains(Status.KICKED_307)) {
|
||||||
// Check if this occupant was kicked
|
// Check if this occupant was kicked
|
||||||
if (isUserModification) {
|
if (isUserModification) {
|
||||||
// Reset occupant information.
|
|
||||||
userHasLeft();
|
|
||||||
|
|
||||||
for (UserStatusListener listener : userStatusListeners) {
|
for (UserStatusListener listener : userStatusListeners) {
|
||||||
listener.kicked(mucUser.getItem().getActor(), mucUser.getItem().getReason());
|
listener.kicked(mucUser.getItem().getActor(), mucUser.getItem().getReason());
|
||||||
}
|
}
|
||||||
|
@ -2455,15 +2455,9 @@ public class MultiUserChat {
|
||||||
if (statusCodes.contains(Status.BANNED_301)) {
|
if (statusCodes.contains(Status.BANNED_301)) {
|
||||||
// Check if this occupant was banned
|
// Check if this occupant was banned
|
||||||
if (isUserModification) {
|
if (isUserModification) {
|
||||||
joined = false;
|
|
||||||
for (UserStatusListener listener : userStatusListeners) {
|
for (UserStatusListener listener : userStatusListeners) {
|
||||||
listener.banned(mucUser.getItem().getActor(), mucUser.getItem().getReason());
|
listener.banned(mucUser.getItem().getActor(), mucUser.getItem().getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset occupant information.
|
|
||||||
occupantsMap.clear();
|
|
||||||
myRoomJid = null;
|
|
||||||
userHasLeft();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (ParticipantStatusListener listener : participantStatusListeners) {
|
for (ParticipantStatusListener listener : participantStatusListeners) {
|
||||||
|
@ -2475,15 +2469,9 @@ public class MultiUserChat {
|
||||||
if (statusCodes.contains(Status.REMOVED_AFFIL_CHANGE_321)) {
|
if (statusCodes.contains(Status.REMOVED_AFFIL_CHANGE_321)) {
|
||||||
// Check if this occupant's membership was revoked
|
// Check if this occupant's membership was revoked
|
||||||
if (isUserModification) {
|
if (isUserModification) {
|
||||||
joined = false;
|
|
||||||
for (UserStatusListener listener : userStatusListeners) {
|
for (UserStatusListener listener : userStatusListeners) {
|
||||||
listener.membershipRevoked();
|
listener.membershipRevoked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset occupant information.
|
|
||||||
occupantsMap.clear();
|
|
||||||
myRoomJid = null;
|
|
||||||
userHasLeft();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// A occupant has changed his nickname in the room
|
// A occupant has changed his nickname in the room
|
||||||
|
@ -2498,11 +2486,6 @@ public class MultiUserChat {
|
||||||
for (UserStatusListener listener : userStatusListeners) {
|
for (UserStatusListener listener : userStatusListeners) {
|
||||||
listener.roomDestroyed(alternateMUC, mucUser.getDestroy().getReason());
|
listener.roomDestroyed(alternateMUC, mucUser.getDestroy().getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset occupant information.
|
|
||||||
occupantsMap.clear();
|
|
||||||
myRoomJid = null;
|
|
||||||
userHasLeft();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue