From 0f01ac20ad135aabbed3f49e8f4dd6427257c067 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 18 Dec 2020 10:35:16 +1100 Subject: [PATCH] Start integrating contact model --- SessionMessagingKit/Contacts/Contact.swift | 19 ++++++++++++++++++ .../MessageReceiver+Handling.swift | 20 +++++++++++-------- Signal.xcodeproj/project.pbxproj | 16 +++++++-------- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/SessionMessagingKit/Contacts/Contact.swift b/SessionMessagingKit/Contacts/Contact.swift index c7ef87541..f29e74c7f 100644 --- a/SessionMessagingKit/Contacts/Contact.swift +++ b/SessionMessagingKit/Contacts/Contact.swift @@ -3,6 +3,8 @@ public class Contact : NSObject, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility public let sessionID: String /// The display name of the contact. + /// + /// - Note: In open groups use `openGroupDisplayName`. public var displayName: String? /// The URL from which to fetch the contact's profile picture. public var profilePictureURL: String? @@ -13,6 +15,16 @@ public class Contact : NSObject, NSCoding { // NSObject/NSCoding conformance is /// The ID of the thread associated with this contact. public var threadID: 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. + public var openGroupDisplayName: String? { + guard let displayName = displayName else { return nil } + let endIndex = sessionID.endIndex + let cutoffIndex = sessionID.index(endIndex, offsetBy: -8) + return "\(displayName) (...\(sessionID[cutoffIndex..