Fix open group display name handling

This commit is contained in:
Niels Andriesse 2021-05-24 12:44:45 +10:00
parent d7afcd07f8
commit 38f50a6dda
2 changed files with 12 additions and 2 deletions

View File

@ -49,6 +49,8 @@ import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.annimon.stream.Stream;
import org.session.libsession.messaging.contacts.Contact;
import org.session.libsession.messaging.jobs.AttachmentDownloadJob;
import org.session.libsession.messaging.jobs.JobQueue;
import org.session.libsession.messaging.open_groups.OpenGroupAPIV2;
@ -889,7 +891,15 @@ public class ConversationItem extends LinearLayout
@SuppressLint("SetTextI18n")
private void setGroupMessageStatus(MessageRecord messageRecord, Recipient recipient) {
if (groupThread && !messageRecord.isOutgoing()) {
String displayName = recipient.toShortString();
String sessionID = recipient.getAddress().serialize();
Contact contact = DatabaseFactory.getSessionContactDatabase(context).getContactWithSessionID(sessionID);
String displayName;
if (contact != null) {
Contact.ContactContext context = (this.conversationRecipient.isOpenGroupRecipient()) ? Contact.ContactContext.OPEN_GROUP : Contact.ContactContext.REGULAR;
displayName = contact.displayName(context);
} else {
displayName = sessionID;
}
this.groupSender.setText(displayName);

View File

@ -44,7 +44,7 @@ class Contact(val sessionID: String) {
// In open groups, where it's more likely that multiple users have the same name,
// we display a bit of the Session ID after a user's display name for added context.
this.name?.let {
return "${this.name}${this.sessionID.takeLast(8)}"
return "${this.name} (...${this.sessionID.takeLast(8)})"
}
return null
}