simplified muc users ordering

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/entities/MucOptions.java | 23 ++--
1 file changed, 12 insertions(+), 11 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/entities/MucOptions.java 🔗

@@ -301,17 +301,18 @@ public class MucOptions {
 			} else if (getAffiliation().outranks(another.getAffiliation())) {
 				return -1;
 			} else {
-				Contact ourContact = getContact();
-				Contact anotherContact = another.getContact();
-				if (ourContact != null && anotherContact != null) {
-					return ourContact.compareTo(anotherContact);
-				} else if (ourContact == null && anotherContact != null) {
-					return getName().compareToIgnoreCase(anotherContact.getDisplayName());
-				} else if (ourContact != null) {
-					return ourContact.getDisplayName().compareToIgnoreCase(another.getName());
-				} else {
-					return getName().compareToIgnoreCase(another.getName());
-				}
+				return getComparableName().compareToIgnoreCase(another.getComparableName());
+			}
+		}
+
+
+		private String getComparableName() {
+			Contact contact = getContact();
+			if (contact != null) {
+				return contact.getDisplayName();
+			} else {
+				String name = getName();
+				return name == null ? "" : name;
 			}
 		}