This commit is contained in:
Niels Andriesse 2020-01-30 20:09:02 +11:00
parent 7e6d0a7dd2
commit a41b670bb5
27 changed files with 74 additions and 51 deletions

View File

@ -578,7 +578,7 @@
B847570323D5698100759540 /* LokiPushNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B847570223D5698100759540 /* LokiPushNotificationManager.swift */; };
B85357BF23A1AE0800AAF6CD /* SeedReminderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357BE23A1AE0800AAF6CD /* SeedReminderView.swift */; };
B85357C123A1B81900AAF6CD /* SeedReminderViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C023A1B81900AAF6CD /* SeedReminderViewDelegate.swift */; };
B85357C323A1BD1200AAF6CD /* SeedVCV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C223A1BD1200AAF6CD /* SeedVCV2.swift */; };
B85357C323A1BD1200AAF6CD /* SeedVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C223A1BD1200AAF6CD /* SeedVC.swift */; };
B85357C523A1F13800AAF6CD /* LinkDeviceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C423A1F13800AAF6CD /* LinkDeviceVC.swift */; };
B85357C723A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C623A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift */; };
B8544E3123D16CA500299F14 /* DeviceUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8544E3023D16CA500299F14 /* DeviceUtilities.swift */; };
@ -1424,7 +1424,7 @@
B847570223D5698100759540 /* LokiPushNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LokiPushNotificationManager.swift; sourceTree = "<group>"; };
B85357BE23A1AE0800AAF6CD /* SeedReminderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedReminderView.swift; sourceTree = "<group>"; };
B85357C023A1B81900AAF6CD /* SeedReminderViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedReminderViewDelegate.swift; sourceTree = "<group>"; };
B85357C223A1BD1200AAF6CD /* SeedVCV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedVCV2.swift; sourceTree = "<group>"; };
B85357C223A1BD1200AAF6CD /* SeedVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedVC.swift; sourceTree = "<group>"; };
B85357C423A1F13800AAF6CD /* LinkDeviceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkDeviceVC.swift; sourceTree = "<group>"; };
B85357C623A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkDeviceVCDelegate.swift; sourceTree = "<group>"; };
B8544E3023D16CA500299F14 /* DeviceUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceUtilities.swift; sourceTree = "<group>"; };
@ -2832,7 +2832,7 @@
B82B408F239DD75000A248E7 /* RestoreVC.swift */,
B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */,
B86BD08523399CEF000F5AE3 /* SeedModal.swift */,
B85357C223A1BD1200AAF6CD /* SeedVCV2.swift */,
B85357C223A1BD1200AAF6CD /* SeedVC.swift */,
B8CCF6422397711F0091D419 /* SettingsVC.swift */,
);
path = "View Controllers";
@ -4011,7 +4011,7 @@
34D1F0B41F86D31D0066283D /* ConversationCollectionView.m in Sources */,
34B3F8821E8DF1700035BE1A /* NewContactThreadViewController.m in Sources */,
45D308AD2049A439000189E4 /* PinEntryView.m in Sources */,
B85357C323A1BD1200AAF6CD /* SeedVCV2.swift in Sources */,
B85357C323A1BD1200AAF6CD /* SeedVC.swift in Sources */,
340FC8B1204DAC8D007AEB0F /* BlockListViewController.m in Sources */,
45B5360E206DD8BB00D61655 /* UIResponder+OWS.swift in Sources */,
4CFE6B6C21F92BA700006701 /* LegacyNotificationsAdaptee.swift in Sources */,

View File

@ -5,7 +5,7 @@
<key>BuildDetails</key>
<dict>
<key>CarthageVersion</key>
<string>0.34.0</string>
<string>0.33.0</string>
<key>OSXVersion</key>
<string>10.15.2</string>
<key>WebRTCCommit</key>

View File

@ -58,6 +58,7 @@ final class ConversationCell : UITableViewCell {
}
private func setUpViewHierarchy() {
let cellHeight: CGFloat = 72
// Set the cell background color
backgroundColor = Colors.cellBackground
// Set up the highlight color
@ -66,7 +67,7 @@ final class ConversationCell : UITableViewCell {
self.selectedBackgroundView = selectedBackgroundView
// Set up the unread messages indicator view
unreadMessagesIndicatorView.set(.width, to: Values.accentLineThickness)
unreadMessagesIndicatorView.set(.height, to: 72)
unreadMessagesIndicatorView.set(.height, to: cellHeight)
// Set up the profile picture view
let profilePictureViewSize = Values.mediumProfilePictureSize
profilePictureView.set(.width, to: profilePictureViewSize)
@ -121,12 +122,12 @@ final class ConversationCell : UITableViewCell {
labelContainerView.pin(.bottom, to: .bottom, of: bottomLabelStackView, withInset: Values.mediumSpacing)
// The two lines below are part of a workaround for a weird layout bug
labelContainerView.set(.width, to: UIScreen.main.bounds.width - Values.accentLineThickness - Values.mediumSpacing - profilePictureViewSize - Values.mediumSpacing - Values.mediumSpacing)
labelContainerView.set(.height, to: 72)
labelContainerView.set(.height, to: cellHeight)
stackView.pin(.leading, to: .leading, of: contentView)
stackView.pin(.top, to: .top, of: contentView)
// The two lines below are part of a workaround for a weird layout bug
stackView.set(.width, to: UIScreen.main.bounds.width - Values.mediumSpacing)
stackView.set(.height, to: 72)
stackView.set(.height, to: cellHeight)
}
// MARK: Updating
@ -180,7 +181,7 @@ final class ConversationCell : UITableViewCell {
private func getDisplayName() -> String {
if threadViewModel.isGroupThread {
if threadViewModel.name.isEmpty || threadViewModel.name == "New Group" {
if threadViewModel.name.isEmpty {
return DisplayNameUtilities.getDisplayName(for: threadViewModel.threadRecord as! TSGroupThread)
} else {
return threadViewModel.name

View File

@ -72,7 +72,7 @@ final class ConversationTitleView : UIView {
private func updateTitle() {
let title: String
if thread.isGroupThread() {
if thread.name().isEmpty || thread.name() == "New Group" {
if thread.name().isEmpty {
title = DisplayNameUtilities.getDisplayName(for: thread as! TSGroupThread)
} else {
title = thread.name()
@ -164,12 +164,7 @@ final class ConversationTitleView : UIView {
let storage = OWSPrimaryStorage.shared()
var userCount: Int?
if thread.groupModel.groupType == .closedGroup {
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
var linkedDeviceHexEncodedPublicKeys: Set<String> = [ userHexEncodedPublicKey ]
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
}
userCount = thread.groupModel.groupMemberIds.filter { !linkedDeviceHexEncodedPublicKeys.contains($0) }.count
userCount = GroupUtilities.getClosedGroupMemberCount(thread)
} else if thread.groupModel.groupType == .openGroup {
storage.dbReadConnection.readWrite { transaction in
if let publicChat = LokiDatabaseUtilities.getPublicChat(for: self.thread.uniqueId!, in: transaction) {

View File

@ -1,7 +1,10 @@
final class TextField : UITextField {
private let usesDefaultHeight: Bool
private let horizontalInset = isSmallScreen ? Values.mediumSpacing : Values.largeSpacing
private let verticalInset = isSmallScreen ? Values.smallSpacing : Values.largeSpacing
init(placeholder: String, usesDefaultHeight: Bool = true) {
self.usesDefaultHeight = usesDefaultHeight
super.init(frame: CGRect.zero)
@ -36,7 +39,7 @@ final class TextField : UITextField {
override func textRect(forBounds bounds: CGRect) -> CGRect {
if usesDefaultHeight {
return bounds.insetBy(dx: isSmallScreen ? Values.mediumSpacing : Values.largeSpacing, dy: isSmallScreen ? Values.smallSpacing : Values.largeSpacing)
return bounds.insetBy(dx: horizontalInset, dy: verticalInset)
} else {
return bounds.insetBy(dx: Values.mediumSpacing, dy: Values.smallSpacing)
}
@ -44,7 +47,7 @@ final class TextField : UITextField {
override func editingRect(forBounds bounds: CGRect) -> CGRect {
if usesDefaultHeight {
return bounds.insetBy(dx: isSmallScreen ? Values.mediumSpacing : Values.largeSpacing, dy: isSmallScreen ? Values.smallSpacing : Values.largeSpacing)
return bounds.insetBy(dx: horizontalInset, dy: verticalInset)
} else {
return bounds.insetBy(dx: Values.mediumSpacing, dy: Values.smallSpacing)
}

View File

@ -9,7 +9,7 @@ public final class MentionUtilities : NSObject {
}
@objc public static func highlightMentions(in string: String, isOutgoingMessage: Bool, threadID: String, attributes: [NSAttributedString.Key:Any]) -> NSAttributedString {
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
var publicChat: LokiPublicChat?
var userLinkedDeviceHexEncodedPublicKeys: Set<String>!
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in

View File

@ -24,8 +24,9 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
private lazy var qrCodeImageView: UIImageView = {
let result = UIImageView()
result.contentMode = .scaleAspectFit
result.set(.width, to: 128)
result.set(.height, to: 128)
let size: CGFloat = 128
result.set(.width, to: size)
result.set(.height, to: size)
return result
}()
@ -116,7 +117,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
stackView.axis = .vertical
switch mode {
case .master:
let hexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let hexEncodedPublicKey = getUserHexEncodedPublicKey()
qrCodeImageView.image = QRCode.generate(for: hexEncodedPublicKey, hasBackground: true)
case .slave:
spinner.set(.height, to: 64)
@ -136,7 +137,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
}()
mnemonicLabel.isHidden = (mode == .master)
if mode == .slave {
let hexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey.removing05PrefixIfNeeded()
let hexEncodedPublicKey = getUserHexEncodedPublicKey().removing05PrefixIfNeeded()
mnemonicLabel.text = Mnemonic.hash(hexEncodedString: hexEncodedPublicKey)
}
authorizeButton.addTarget(self, action: #selector(authorizeDeviceLink), for: UIControl.Event.touchUpInside)

View File

@ -86,7 +86,7 @@ final class DeviceLinksVC : UIViewController, UITableViewDataSource, UITableView
// MARK: Updating
private func updateDeviceLinks() {
let storage = OWSPrimaryStorage.shared()
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
var deviceLinks: [DeviceLink] = []
storage.dbReadConnection.read { transaction in
deviceLinks = storage.getDeviceLinks(for: userHexEncodedPublicKey, in: transaction).sorted { lhs, rhs in

View File

@ -7,12 +7,7 @@ final class GroupMembersVC : UIViewController, UITableViewDataSource {
func getDisplayName(for hexEncodedPublicKey: String) -> String {
return DisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"
}
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
var linkedDeviceHexEncodedPublicKeys: Set<String> = [ userHexEncodedPublicKey ]
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
}
return thread.groupModel.groupMemberIds.filter { !linkedDeviceHexEncodedPublicKeys.contains($0) }.sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
return GroupUtilities.getClosedGroupMembers(thread).sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
}()
// MARK: Components

View File

@ -244,7 +244,7 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat
let profilePictureSize = Values.verySmallProfilePictureSize
let profilePictureView = ProfilePictureView()
profilePictureView.size = profilePictureSize
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
profilePictureView.hexEncodedPublicKey = userHexEncodedPublicKey
profilePictureView.update()
profilePictureView.set(.width, to: profilePictureSize)
@ -267,7 +267,7 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat
// MARK: Interaction
func handleContinueButtonTapped(from seedReminderView: SeedReminderView) {
let seedVC = SeedVCV2()
let seedVC = SeedVC()
let navigationController = OWSNavigationController(rootViewController: seedVC)
present(navigationController, animated: true, completion: nil)
}

View File

@ -12,7 +12,7 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV
func getDisplayName(for hexEncodedPublicKey: String) -> String {
return DisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"
}
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
var linkedDeviceHexEncodedPublicKeys: Set<String> = [ userHexEncodedPublicKey ]
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
@ -147,7 +147,7 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV
guard selectedContacts.count >= 2 else {
return showError(title: NSLocalizedString("Please pick at least 2 group members", comment: ""))
}
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
let members = [String](selectedContacts) + [ userHexEncodedPublicKey ]
let admins = [ userHexEncodedPublicKey ]
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(Randomness.generateRandomBytes(kGroupIdLength)!.toHexString())

View File

@ -158,7 +158,7 @@ private final class EnterPublicKeyVC : UIViewController {
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
return masterHexEncodedPublicKey
} else {
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
return getUserHexEncodedPublicKey()
}
}()

View File

@ -155,7 +155,7 @@ private final class ViewMyQRCodeVC : UIViewController {
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
return masterHexEncodedPublicKey
} else {
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
return getUserHexEncodedPublicKey()
}
}()

View File

@ -1,5 +1,5 @@
final class SeedVCV2 : UIViewController {
final class SeedVC : UIViewController {
private let mnemonic: String = {
let identityManager = OWSIdentityManager.shared()

View File

@ -8,7 +8,7 @@ final class SettingsVC : UIViewController, AvatarViewHelperDelegate {
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
return masterHexEncodedPublicKey
} else {
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
return getUserHexEncodedPublicKey()
}
}()

View File

@ -88,7 +88,7 @@ public class AvatarImageView: UIImageView {
let peerInfo = LokiP2PAPI.getInfo(for: contactID)
let isOnline = peerInfo?.isOnline ?? false
let color: UIColor = isOnline ? .lokiGreen() : .lokiGray()
let currentUserID = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let currentUserID = getUserHexEncodedPublicKey()
let isCurrentUser = (contactID == currentUserID)
layer.borderColor = isCurrentUser ? UIColor.clear.cgColor : color.cgColor
}

View File

@ -9,7 +9,7 @@ public final class LokiAPI : NSObject {
// MARK: Convenience
internal static let storage = OWSPrimaryStorage.shared()
internal static let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
internal static let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
// MARK: Settings
private static let version = "v1"

View File

@ -14,7 +14,7 @@ public final class LokiLongPoller : NSObject {
private let retryInterval: TimeInterval = 4
// MARK: Convenience
private var userHexEncodedPublicKey: String { return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey }
private var userHexEncodedPublicKey: String { return getUserHexEncodedPublicKey() }
// MARK: Initialization
@objc public init(onMessagesReceived: @escaping ([SSKProtoEnvelope]) -> Void) {

View File

@ -6,7 +6,7 @@ public class LokiP2PAPI : NSObject {
private static let storage = OWSPrimaryStorage.shared()
private static let messageSender = SSKEnvironment.shared.messageSender
private static let messageReceiver = SSKEnvironment.shared.messageReceiver
private static let ourHexEncodedPubKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
private static let ourHexEncodedPubKey = getUserHexEncodedPublicKey()
/// The amount of time before pinging when a user is set to offline
private static let offlinePingTime = 2 * kMinuteInterval

View File

@ -7,7 +7,7 @@ public final class DeviceLink : NSObject, NSCoding {
@objc public var isAuthorized: Bool { return master.signature != nil }
@objc public var other: Device {
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
return (userHexEncodedPublicKey == master.hexEncodedPublicKey) ? slave : master
}

View File

@ -31,7 +31,7 @@ public final class DeviceLinkingSession : NSObject {
}
@objc public func processLinkingRequest(from slaveHexEncodedPublicKey: String, to masterHexEncodedPublicKey: String, with slaveSignature: Data) {
guard isListeningForLinkingRequests, !isProcessingLinkingRequest, masterHexEncodedPublicKey == OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey else { return }
guard isListeningForLinkingRequests, !isProcessingLinkingRequest, masterHexEncodedPublicKey == getUserHexEncodedPublicKey() else { return }
let master = DeviceLink.Device(hexEncodedPublicKey: masterHexEncodedPublicKey)
let slave = DeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
let deviceLink = DeviceLink(between: master, and: slave)
@ -43,7 +43,7 @@ public final class DeviceLinkingSession : NSObject {
}
@objc public func processLinkingAuthorization(from masterHexEncodedPublicKey: String, for slaveHexEncodedPublicKey: String, masterSignature: Data, slaveSignature: Data) {
guard isListeningForLinkingAuthorization, slaveHexEncodedPublicKey == OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey else { return }
guard isListeningForLinkingAuthorization, slaveHexEncodedPublicKey == getUserHexEncodedPublicKey() else { return }
let master = DeviceLink.Device(hexEncodedPublicKey: masterHexEncodedPublicKey, signature: masterSignature)
let slave = DeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
let deviceLink = DeviceLink(between: master, and: slave)

View File

@ -10,7 +10,7 @@ public final class LokiPublicChatPoller : NSObject {
private var pollForModeratorsTimer: Timer? = nil
private var pollForDisplayNamesTimer: Timer? = nil
private var hasStarted = false
private let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
private let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
// MARK: Settings
private let pollForNewMessagesInterval: TimeInterval = 4

View File

@ -12,7 +12,7 @@ public final class LokiDatabaseUtilities : NSObject {
if let message = interaction as? TSIncomingMessage {
senderHexEncodedPublicKey = message.authorId
} else if let message = interaction as? TSOutgoingMessage {
senderHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
senderHexEncodedPublicKey = getUserHexEncodedPublicKey()
} else {
return false
}
@ -40,7 +40,7 @@ public final class LokiDatabaseUtilities : NSObject {
@objc(isUserLinkedDevice:in:)
public static func isUserLinkedDevice(_ hexEncodedPublicKey: String, transaction: YapDatabaseReadTransaction) -> Bool {
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
let userLinkedDeviceHexEncodedPublicKeys = getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
return userLinkedDeviceHexEncodedPublicKeys.contains(hexEncodedPublicKey)
}

View File

@ -7,7 +7,7 @@ public final class DisplayNameUtilities : NSObject {
override private init() { }
private static var userHexEncodedPublicKey: String {
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
return getUserHexEncodedPublicKey()
}
private static var userDisplayName: String? {

View File

@ -0,0 +1,4 @@
public func getUserHexEncodedPublicKey() -> String {
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
}

View File

@ -0,0 +1,25 @@
public enum GroupUtilities {
public static func getClosedGroupMembers(_ closedGroup: TSGroupThread) -> [String] {
var result: [String]!
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
result = getClosedGroupMembers(closedGroup, with: transaction)
}
return result
}
public static func getClosedGroupMembers(_ closedGroup: TSGroupThread, with transaction: YapDatabaseReadTransaction) -> [String] {
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
let linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
return closedGroup.groupModel.groupMemberIds.filter { !linkedDeviceHexEncodedPublicKeys.contains($0) }
}
public static func getClosedGroupMemberCount(_ closedGroup: TSGroupThread) -> Int {
return getClosedGroupMembers(closedGroup).count
}
public static func getClosedGroupMemberCount(_ closedGroup: TSGroupThread, with transaction: YapDatabaseReadTransaction) -> Int {
return getClosedGroupMembers(closedGroup, with: transaction).count
}
}

View File

@ -577,7 +577,6 @@ NS_ASSUME_NONNULL_BEGIN
[self handleProfileKeyUpdateIfNeeded:dataMessage recipientId:envelope.source];
if (dataMessage.group) {
TSGroupThread *_Nullable groupThread =
[TSGroupThread threadWithGroupId:dataMessage.group.id transaction:transaction];