diff --git a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift index 3aa8e7e64..1bb5fd373 100644 --- a/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift +++ b/Signal/src/Loki/View Controllers/NewClosedGroupVC.swift @@ -4,10 +4,16 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV private lazy var contacts: [String] = { var result: [String] = [] - TSContactThread.enumerateCollectionObjects { object, _ in - guard let thread = object as? TSContactThread, thread.isContactFriend else { return } - let hexEncodedPublicKey = thread.contactIdentifier() - result.append(hexEncodedPublicKey) + let storage = OWSPrimaryStorage.shared() + storage.dbReadConnection.read { transaction in + TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in + guard let thread = object as? TSContactThread, thread.isContactFriend else { return } + let hexEncodedPublicKey = thread.contactIdentifier() + // We shouldn't be able to add slave devices to groups + if (storage.getMasterHexEncodedPublicKey(for: hexEncodedPublicKey, in: transaction) == nil) { + result.append(hexEncodedPublicKey) + } + } } func getDisplayName(for hexEncodedPublicKey: String) -> String { return UserDisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact" diff --git a/SignalServiceKit/src/Loki/Utilities/GroupUtilities.swift b/SignalServiceKit/src/Loki/Utilities/GroupUtilities.swift index 5486fef8e..0b5478ed1 100644 --- a/SignalServiceKit/src/Loki/Utilities/GroupUtilities.swift +++ b/SignalServiceKit/src/Loki/Utilities/GroupUtilities.swift @@ -10,10 +10,12 @@ public enum GroupUtilities { } public static func getClosedGroupMembers(_ closedGroup: TSGroupThread, with transaction: YapDatabaseReadTransaction) -> [String] { + let storage = OWSPrimaryStorage.shared() let userHexEncodedPublicKey = getUserHexEncodedPublicKey() - var linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction) - linkedDeviceHexEncodedPublicKeys.remove(userHexEncodedPublicKey) // Show the user as a member - return closedGroup.groupModel.groupMemberIds.filter { !linkedDeviceHexEncodedPublicKeys.contains($0) } + return closedGroup.groupModel.groupMemberIds.filter { member in + // Don't show any slave devices + return storage.getMasterHexEncodedPublicKey(for: member, in: transaction) == nil + } } public static func getClosedGroupMemberCount(_ closedGroup: TSGroupThread) -> Int {