diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index b7307a8b1..28c052b70 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -255,8 +255,10 @@ public class Contact implements ListItem, Blockable { this.serverName = serverName; } - public void setSystemName(String systemName) { + public boolean setSystemName(String systemName) { + String old = this.systemName; this.systemName = systemName; + return (old == null && systemName != null) || (old != null && !old.equals(systemName)); } public void setPresenceName(String presenceName) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 0fce323da..93981f4a4 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1518,16 +1518,18 @@ public class XmppConnectionService extends Service { + "#" + phoneContact.getString("lookup"); contact.setSystemAccount(systemAccount); - if (contact.setPhotoUri(phoneContact.getString("photouri"))) { + boolean needsCacheClean = contact.setPhotoUri(phoneContact.getString("photouri")); + needsCacheClean |= contact.setSystemName(phoneContact.getString("displayname")); + if (needsCacheClean) { getAvatarService().clear(contact); } - contact.setSystemName(phoneContact.getString("displayname")); withSystemAccounts.remove(contact); } for (Contact contact : withSystemAccounts) { contact.setSystemAccount(null); - contact.setSystemName(null); - if (contact.setPhotoUri(null)) { + boolean needsCacheClean = contact.setPhotoUri(null); + needsCacheClean |= contact.setSystemName(null); + if (needsCacheClean) { getAvatarService().clear(contact); } }