diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-11-29 13:43:52 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-11-29 13:43:52 +0100 |
commit | 9e7a54849d1d2d79072c5cd2f6a9870978e617c9 (patch) | |
tree | f38a9bbcb718dced793f3a62574377e7c65efe80 /src | |
parent | 33e6d8a1ce2832c2300865e57214a72b63f661a7 (diff) |
better handle the case when same user is joined with multiple nicks in the same room
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/MucOptions.java | 32 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/AvatarService.java | 2 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 8e67aa41..93925299 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -3,7 +3,6 @@ package eu.siacs.conversations.entities; import android.annotation.SuppressLint; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -395,10 +394,18 @@ public class MucOptions { if (user != null) { synchronized (users) { users.remove(user); - if (membersOnly() && - nonanonymous() && - user.affiliation.ranks(Affiliation.MEMBER) && - user.realJid != null) { + boolean realJidInMuc = false; + for (User u : users) { + if (user.realJid != null && user.realJid.equals(u.realJid)) { + realJidInMuc = true; + break; + } + } + if (membersOnly() + && nonanonymous() + && user.affiliation.ranks(Affiliation.MEMBER) + && user.realJid != null + && !realJidInMuc) { user.role = Role.NONE; user.avatar = null; user.fullJid = null; @@ -508,8 +515,19 @@ public class MucOptions { } public List<User> getUsers(int max) { - ArrayList<User> users = getUsers(); - return users.subList(0, Math.min(max, users.size())); + ArrayList<User> subset = new ArrayList<>(); + HashSet<Jid> jids = new HashSet<>(); + synchronized (users) { + for(User user : users) { + if (user.getRealJid() == null || jids.add(user.getRealJid())) { + subset.add(user); + } + if (subset.size() >= max) { + break; + } + } + } + return subset; } public int getUserCount() { diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index a6bf8875..4b4d1ed3 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -172,7 +172,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { if (bitmap != null || cachedOnly) { return bitmap; } - final List<MucOptions.User> users = mucOptions.getUsers(); + final List<MucOptions.User> users = mucOptions.getUsers(5); int count = users.size(); bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); |