mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Refactor
This commit is contained in:
parent
7e6d0a7dd2
commit
a41b670bb5
|
@ -578,7 +578,7 @@
|
||||||
B847570323D5698100759540 /* LokiPushNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B847570223D5698100759540 /* LokiPushNotificationManager.swift */; };
|
B847570323D5698100759540 /* LokiPushNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B847570223D5698100759540 /* LokiPushNotificationManager.swift */; };
|
||||||
B85357BF23A1AE0800AAF6CD /* SeedReminderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357BE23A1AE0800AAF6CD /* SeedReminderView.swift */; };
|
B85357BF23A1AE0800AAF6CD /* SeedReminderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357BE23A1AE0800AAF6CD /* SeedReminderView.swift */; };
|
||||||
B85357C123A1B81900AAF6CD /* SeedReminderViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C023A1B81900AAF6CD /* SeedReminderViewDelegate.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 */; };
|
B85357C523A1F13800AAF6CD /* LinkDeviceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C423A1F13800AAF6CD /* LinkDeviceVC.swift */; };
|
||||||
B85357C723A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C623A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift */; };
|
B85357C723A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85357C623A1FB5100AAF6CD /* LinkDeviceVCDelegate.swift */; };
|
||||||
B8544E3123D16CA500299F14 /* DeviceUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8544E3023D16CA500299F14 /* DeviceUtilities.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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
B8544E3023D16CA500299F14 /* DeviceUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceUtilities.swift; sourceTree = "<group>"; };
|
||||||
|
@ -2832,7 +2832,7 @@
|
||||||
B82B408F239DD75000A248E7 /* RestoreVC.swift */,
|
B82B408F239DD75000A248E7 /* RestoreVC.swift */,
|
||||||
B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */,
|
B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */,
|
||||||
B86BD08523399CEF000F5AE3 /* SeedModal.swift */,
|
B86BD08523399CEF000F5AE3 /* SeedModal.swift */,
|
||||||
B85357C223A1BD1200AAF6CD /* SeedVCV2.swift */,
|
B85357C223A1BD1200AAF6CD /* SeedVC.swift */,
|
||||||
B8CCF6422397711F0091D419 /* SettingsVC.swift */,
|
B8CCF6422397711F0091D419 /* SettingsVC.swift */,
|
||||||
);
|
);
|
||||||
path = "View Controllers";
|
path = "View Controllers";
|
||||||
|
@ -4011,7 +4011,7 @@
|
||||||
34D1F0B41F86D31D0066283D /* ConversationCollectionView.m in Sources */,
|
34D1F0B41F86D31D0066283D /* ConversationCollectionView.m in Sources */,
|
||||||
34B3F8821E8DF1700035BE1A /* NewContactThreadViewController.m in Sources */,
|
34B3F8821E8DF1700035BE1A /* NewContactThreadViewController.m in Sources */,
|
||||||
45D308AD2049A439000189E4 /* PinEntryView.m in Sources */,
|
45D308AD2049A439000189E4 /* PinEntryView.m in Sources */,
|
||||||
B85357C323A1BD1200AAF6CD /* SeedVCV2.swift in Sources */,
|
B85357C323A1BD1200AAF6CD /* SeedVC.swift in Sources */,
|
||||||
340FC8B1204DAC8D007AEB0F /* BlockListViewController.m in Sources */,
|
340FC8B1204DAC8D007AEB0F /* BlockListViewController.m in Sources */,
|
||||||
45B5360E206DD8BB00D61655 /* UIResponder+OWS.swift in Sources */,
|
45B5360E206DD8BB00D61655 /* UIResponder+OWS.swift in Sources */,
|
||||||
4CFE6B6C21F92BA700006701 /* LegacyNotificationsAdaptee.swift in Sources */,
|
4CFE6B6C21F92BA700006701 /* LegacyNotificationsAdaptee.swift in Sources */,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<key>BuildDetails</key>
|
<key>BuildDetails</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CarthageVersion</key>
|
<key>CarthageVersion</key>
|
||||||
<string>0.34.0</string>
|
<string>0.33.0</string>
|
||||||
<key>OSXVersion</key>
|
<key>OSXVersion</key>
|
||||||
<string>10.15.2</string>
|
<string>10.15.2</string>
|
||||||
<key>WebRTCCommit</key>
|
<key>WebRTCCommit</key>
|
||||||
|
|
|
@ -58,6 +58,7 @@ final class ConversationCell : UITableViewCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setUpViewHierarchy() {
|
private func setUpViewHierarchy() {
|
||||||
|
let cellHeight: CGFloat = 72
|
||||||
// Set the cell background color
|
// Set the cell background color
|
||||||
backgroundColor = Colors.cellBackground
|
backgroundColor = Colors.cellBackground
|
||||||
// Set up the highlight color
|
// Set up the highlight color
|
||||||
|
@ -66,7 +67,7 @@ final class ConversationCell : UITableViewCell {
|
||||||
self.selectedBackgroundView = selectedBackgroundView
|
self.selectedBackgroundView = selectedBackgroundView
|
||||||
// Set up the unread messages indicator view
|
// Set up the unread messages indicator view
|
||||||
unreadMessagesIndicatorView.set(.width, to: Values.accentLineThickness)
|
unreadMessagesIndicatorView.set(.width, to: Values.accentLineThickness)
|
||||||
unreadMessagesIndicatorView.set(.height, to: 72)
|
unreadMessagesIndicatorView.set(.height, to: cellHeight)
|
||||||
// Set up the profile picture view
|
// Set up the profile picture view
|
||||||
let profilePictureViewSize = Values.mediumProfilePictureSize
|
let profilePictureViewSize = Values.mediumProfilePictureSize
|
||||||
profilePictureView.set(.width, to: profilePictureViewSize)
|
profilePictureView.set(.width, to: profilePictureViewSize)
|
||||||
|
@ -121,12 +122,12 @@ final class ConversationCell : UITableViewCell {
|
||||||
labelContainerView.pin(.bottom, to: .bottom, of: bottomLabelStackView, withInset: Values.mediumSpacing)
|
labelContainerView.pin(.bottom, to: .bottom, of: bottomLabelStackView, withInset: Values.mediumSpacing)
|
||||||
// The two lines below are part of a workaround for a weird layout bug
|
// 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(.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(.leading, to: .leading, of: contentView)
|
||||||
stackView.pin(.top, to: .top, of: contentView)
|
stackView.pin(.top, to: .top, of: contentView)
|
||||||
// The two lines below are part of a workaround for a weird layout bug
|
// 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(.width, to: UIScreen.main.bounds.width - Values.mediumSpacing)
|
||||||
stackView.set(.height, to: 72)
|
stackView.set(.height, to: cellHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Updating
|
// MARK: Updating
|
||||||
|
@ -180,7 +181,7 @@ final class ConversationCell : UITableViewCell {
|
||||||
|
|
||||||
private func getDisplayName() -> String {
|
private func getDisplayName() -> String {
|
||||||
if threadViewModel.isGroupThread {
|
if threadViewModel.isGroupThread {
|
||||||
if threadViewModel.name.isEmpty || threadViewModel.name == "New Group" {
|
if threadViewModel.name.isEmpty {
|
||||||
return DisplayNameUtilities.getDisplayName(for: threadViewModel.threadRecord as! TSGroupThread)
|
return DisplayNameUtilities.getDisplayName(for: threadViewModel.threadRecord as! TSGroupThread)
|
||||||
} else {
|
} else {
|
||||||
return threadViewModel.name
|
return threadViewModel.name
|
||||||
|
|
|
@ -72,7 +72,7 @@ final class ConversationTitleView : UIView {
|
||||||
private func updateTitle() {
|
private func updateTitle() {
|
||||||
let title: String
|
let title: String
|
||||||
if thread.isGroupThread() {
|
if thread.isGroupThread() {
|
||||||
if thread.name().isEmpty || thread.name() == "New Group" {
|
if thread.name().isEmpty {
|
||||||
title = DisplayNameUtilities.getDisplayName(for: thread as! TSGroupThread)
|
title = DisplayNameUtilities.getDisplayName(for: thread as! TSGroupThread)
|
||||||
} else {
|
} else {
|
||||||
title = thread.name()
|
title = thread.name()
|
||||||
|
@ -164,12 +164,7 @@ final class ConversationTitleView : UIView {
|
||||||
let storage = OWSPrimaryStorage.shared()
|
let storage = OWSPrimaryStorage.shared()
|
||||||
var userCount: Int?
|
var userCount: Int?
|
||||||
if thread.groupModel.groupType == .closedGroup {
|
if thread.groupModel.groupType == .closedGroup {
|
||||||
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
userCount = GroupUtilities.getClosedGroupMemberCount(thread)
|
||||||
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
|
|
||||||
} else if thread.groupModel.groupType == .openGroup {
|
} else if thread.groupModel.groupType == .openGroup {
|
||||||
storage.dbReadConnection.readWrite { transaction in
|
storage.dbReadConnection.readWrite { transaction in
|
||||||
if let publicChat = LokiDatabaseUtilities.getPublicChat(for: self.thread.uniqueId!, in: transaction) {
|
if let publicChat = LokiDatabaseUtilities.getPublicChat(for: self.thread.uniqueId!, in: transaction) {
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
final class TextField : UITextField {
|
final class TextField : UITextField {
|
||||||
private let usesDefaultHeight: Bool
|
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) {
|
init(placeholder: String, usesDefaultHeight: Bool = true) {
|
||||||
self.usesDefaultHeight = usesDefaultHeight
|
self.usesDefaultHeight = usesDefaultHeight
|
||||||
super.init(frame: CGRect.zero)
|
super.init(frame: CGRect.zero)
|
||||||
|
@ -36,7 +39,7 @@ final class TextField : UITextField {
|
||||||
|
|
||||||
override func textRect(forBounds bounds: CGRect) -> CGRect {
|
override func textRect(forBounds bounds: CGRect) -> CGRect {
|
||||||
if usesDefaultHeight {
|
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 {
|
} else {
|
||||||
return bounds.insetBy(dx: Values.mediumSpacing, dy: Values.smallSpacing)
|
return bounds.insetBy(dx: Values.mediumSpacing, dy: Values.smallSpacing)
|
||||||
}
|
}
|
||||||
|
@ -44,7 +47,7 @@ final class TextField : UITextField {
|
||||||
|
|
||||||
override func editingRect(forBounds bounds: CGRect) -> CGRect {
|
override func editingRect(forBounds bounds: CGRect) -> CGRect {
|
||||||
if usesDefaultHeight {
|
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 {
|
} else {
|
||||||
return bounds.insetBy(dx: Values.mediumSpacing, dy: Values.smallSpacing)
|
return bounds.insetBy(dx: Values.mediumSpacing, dy: Values.smallSpacing)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
@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 publicChat: LokiPublicChat?
|
||||||
var userLinkedDeviceHexEncodedPublicKeys: Set<String>!
|
var userLinkedDeviceHexEncodedPublicKeys: Set<String>!
|
||||||
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
|
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
|
||||||
|
|
|
@ -24,8 +24,9 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
|
||||||
private lazy var qrCodeImageView: UIImageView = {
|
private lazy var qrCodeImageView: UIImageView = {
|
||||||
let result = UIImageView()
|
let result = UIImageView()
|
||||||
result.contentMode = .scaleAspectFit
|
result.contentMode = .scaleAspectFit
|
||||||
result.set(.width, to: 128)
|
let size: CGFloat = 128
|
||||||
result.set(.height, to: 128)
|
result.set(.width, to: size)
|
||||||
|
result.set(.height, to: size)
|
||||||
return result
|
return result
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
switch mode {
|
switch mode {
|
||||||
case .master:
|
case .master:
|
||||||
let hexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
let hexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
qrCodeImageView.image = QRCode.generate(for: hexEncodedPublicKey, hasBackground: true)
|
qrCodeImageView.image = QRCode.generate(for: hexEncodedPublicKey, hasBackground: true)
|
||||||
case .slave:
|
case .slave:
|
||||||
spinner.set(.height, to: 64)
|
spinner.set(.height, to: 64)
|
||||||
|
@ -136,7 +137,7 @@ final class DeviceLinkingModal : Modal, DeviceLinkingSessionDelegate {
|
||||||
}()
|
}()
|
||||||
mnemonicLabel.isHidden = (mode == .master)
|
mnemonicLabel.isHidden = (mode == .master)
|
||||||
if mode == .slave {
|
if mode == .slave {
|
||||||
let hexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey.removing05PrefixIfNeeded()
|
let hexEncodedPublicKey = getUserHexEncodedPublicKey().removing05PrefixIfNeeded()
|
||||||
mnemonicLabel.text = Mnemonic.hash(hexEncodedString: hexEncodedPublicKey)
|
mnemonicLabel.text = Mnemonic.hash(hexEncodedString: hexEncodedPublicKey)
|
||||||
}
|
}
|
||||||
authorizeButton.addTarget(self, action: #selector(authorizeDeviceLink), for: UIControl.Event.touchUpInside)
|
authorizeButton.addTarget(self, action: #selector(authorizeDeviceLink), for: UIControl.Event.touchUpInside)
|
||||||
|
|
|
@ -86,7 +86,7 @@ final class DeviceLinksVC : UIViewController, UITableViewDataSource, UITableView
|
||||||
// MARK: Updating
|
// MARK: Updating
|
||||||
private func updateDeviceLinks() {
|
private func updateDeviceLinks() {
|
||||||
let storage = OWSPrimaryStorage.shared()
|
let storage = OWSPrimaryStorage.shared()
|
||||||
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
var deviceLinks: [DeviceLink] = []
|
var deviceLinks: [DeviceLink] = []
|
||||||
storage.dbReadConnection.read { transaction in
|
storage.dbReadConnection.read { transaction in
|
||||||
deviceLinks = storage.getDeviceLinks(for: userHexEncodedPublicKey, in: transaction).sorted { lhs, rhs in
|
deviceLinks = storage.getDeviceLinks(for: userHexEncodedPublicKey, in: transaction).sorted { lhs, rhs in
|
||||||
|
|
|
@ -7,12 +7,7 @@ final class GroupMembersVC : UIViewController, UITableViewDataSource {
|
||||||
func getDisplayName(for hexEncodedPublicKey: String) -> String {
|
func getDisplayName(for hexEncodedPublicKey: String) -> String {
|
||||||
return DisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"
|
return DisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"
|
||||||
}
|
}
|
||||||
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
return GroupUtilities.getClosedGroupMembers(thread).sorted { getDisplayName(for: $0) < getDisplayName(for: $1) }
|
||||||
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) }
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// MARK: Components
|
// MARK: Components
|
||||||
|
|
|
@ -244,7 +244,7 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat
|
||||||
let profilePictureSize = Values.verySmallProfilePictureSize
|
let profilePictureSize = Values.verySmallProfilePictureSize
|
||||||
let profilePictureView = ProfilePictureView()
|
let profilePictureView = ProfilePictureView()
|
||||||
profilePictureView.size = profilePictureSize
|
profilePictureView.size = profilePictureSize
|
||||||
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
profilePictureView.hexEncodedPublicKey = userHexEncodedPublicKey
|
profilePictureView.hexEncodedPublicKey = userHexEncodedPublicKey
|
||||||
profilePictureView.update()
|
profilePictureView.update()
|
||||||
profilePictureView.set(.width, to: profilePictureSize)
|
profilePictureView.set(.width, to: profilePictureSize)
|
||||||
|
@ -267,7 +267,7 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat
|
||||||
|
|
||||||
// MARK: Interaction
|
// MARK: Interaction
|
||||||
func handleContinueButtonTapped(from seedReminderView: SeedReminderView) {
|
func handleContinueButtonTapped(from seedReminderView: SeedReminderView) {
|
||||||
let seedVC = SeedVCV2()
|
let seedVC = SeedVC()
|
||||||
let navigationController = OWSNavigationController(rootViewController: seedVC)
|
let navigationController = OWSNavigationController(rootViewController: seedVC)
|
||||||
present(navigationController, animated: true, completion: nil)
|
present(navigationController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV
|
||||||
func getDisplayName(for hexEncodedPublicKey: String) -> String {
|
func getDisplayName(for hexEncodedPublicKey: String) -> String {
|
||||||
return DisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"
|
return DisplayNameUtilities.getPrivateChatDisplayName(for: hexEncodedPublicKey) ?? "Unknown Contact"
|
||||||
}
|
}
|
||||||
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
var linkedDeviceHexEncodedPublicKeys: Set<String> = [ userHexEncodedPublicKey ]
|
var linkedDeviceHexEncodedPublicKeys: Set<String> = [ userHexEncodedPublicKey ]
|
||||||
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
|
OWSPrimaryStorage.shared().dbReadConnection.read { transaction in
|
||||||
linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
|
linkedDeviceHexEncodedPublicKeys = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
|
||||||
|
@ -147,7 +147,7 @@ final class NewClosedGroupVC : UIViewController, UITableViewDataSource, UITableV
|
||||||
guard selectedContacts.count >= 2 else {
|
guard selectedContacts.count >= 2 else {
|
||||||
return showError(title: NSLocalizedString("Please pick at least 2 group members", comment: ""))
|
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 members = [String](selectedContacts) + [ userHexEncodedPublicKey ]
|
||||||
let admins = [ userHexEncodedPublicKey ]
|
let admins = [ userHexEncodedPublicKey ]
|
||||||
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(Randomness.generateRandomBytes(kGroupIdLength)!.toHexString())
|
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(Randomness.generateRandomBytes(kGroupIdLength)!.toHexString())
|
||||||
|
|
|
@ -158,7 +158,7 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
|
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
|
||||||
return masterHexEncodedPublicKey
|
return masterHexEncodedPublicKey
|
||||||
} else {
|
} else {
|
||||||
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
return getUserHexEncodedPublicKey()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ private final class ViewMyQRCodeVC : UIViewController {
|
||||||
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
|
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
|
||||||
return masterHexEncodedPublicKey
|
return masterHexEncodedPublicKey
|
||||||
} else {
|
} else {
|
||||||
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
return getUserHexEncodedPublicKey()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
final class SeedVCV2 : UIViewController {
|
final class SeedVC : UIViewController {
|
||||||
|
|
||||||
private let mnemonic: String = {
|
private let mnemonic: String = {
|
||||||
let identityManager = OWSIdentityManager.shared()
|
let identityManager = OWSIdentityManager.shared()
|
|
@ -8,7 +8,7 @@ final class SettingsVC : UIViewController, AvatarViewHelperDelegate {
|
||||||
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
|
if let masterHexEncodedPublicKey = UserDefaults.standard.string(forKey: "masterDeviceHexEncodedPublicKey") {
|
||||||
return masterHexEncodedPublicKey
|
return masterHexEncodedPublicKey
|
||||||
} else {
|
} else {
|
||||||
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
return getUserHexEncodedPublicKey()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class AvatarImageView: UIImageView {
|
||||||
let peerInfo = LokiP2PAPI.getInfo(for: contactID)
|
let peerInfo = LokiP2PAPI.getInfo(for: contactID)
|
||||||
let isOnline = peerInfo?.isOnline ?? false
|
let isOnline = peerInfo?.isOnline ?? false
|
||||||
let color: UIColor = isOnline ? .lokiGreen() : .lokiGray()
|
let color: UIColor = isOnline ? .lokiGreen() : .lokiGray()
|
||||||
let currentUserID = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
let currentUserID = getUserHexEncodedPublicKey()
|
||||||
let isCurrentUser = (contactID == currentUserID)
|
let isCurrentUser = (contactID == currentUserID)
|
||||||
layer.borderColor = isCurrentUser ? UIColor.clear.cgColor : color.cgColor
|
layer.borderColor = isCurrentUser ? UIColor.clear.cgColor : color.cgColor
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public final class LokiAPI : NSObject {
|
||||||
|
|
||||||
// MARK: Convenience
|
// MARK: Convenience
|
||||||
internal static let storage = OWSPrimaryStorage.shared()
|
internal static let storage = OWSPrimaryStorage.shared()
|
||||||
internal static let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
internal static let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
|
|
||||||
// MARK: Settings
|
// MARK: Settings
|
||||||
private static let version = "v1"
|
private static let version = "v1"
|
||||||
|
|
|
@ -14,7 +14,7 @@ public final class LokiLongPoller : NSObject {
|
||||||
private let retryInterval: TimeInterval = 4
|
private let retryInterval: TimeInterval = 4
|
||||||
|
|
||||||
// MARK: Convenience
|
// MARK: Convenience
|
||||||
private var userHexEncodedPublicKey: String { return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey }
|
private var userHexEncodedPublicKey: String { return getUserHexEncodedPublicKey() }
|
||||||
|
|
||||||
// MARK: Initialization
|
// MARK: Initialization
|
||||||
@objc public init(onMessagesReceived: @escaping ([SSKProtoEnvelope]) -> Void) {
|
@objc public init(onMessagesReceived: @escaping ([SSKProtoEnvelope]) -> Void) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ public class LokiP2PAPI : NSObject {
|
||||||
private static let storage = OWSPrimaryStorage.shared()
|
private static let storage = OWSPrimaryStorage.shared()
|
||||||
private static let messageSender = SSKEnvironment.shared.messageSender
|
private static let messageSender = SSKEnvironment.shared.messageSender
|
||||||
private static let messageReceiver = SSKEnvironment.shared.messageReceiver
|
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
|
/// The amount of time before pinging when a user is set to offline
|
||||||
private static let offlinePingTime = 2 * kMinuteInterval
|
private static let offlinePingTime = 2 * kMinuteInterval
|
||||||
|
|
|
@ -7,7 +7,7 @@ public final class DeviceLink : NSObject, NSCoding {
|
||||||
@objc public var isAuthorized: Bool { return master.signature != nil }
|
@objc public var isAuthorized: Bool { return master.signature != nil }
|
||||||
|
|
||||||
@objc public var other: Device {
|
@objc public var other: Device {
|
||||||
let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
return (userHexEncodedPublicKey == master.hexEncodedPublicKey) ? slave : master
|
return (userHexEncodedPublicKey == master.hexEncodedPublicKey) ? slave : master
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public final class DeviceLinkingSession : NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func processLinkingRequest(from slaveHexEncodedPublicKey: String, to masterHexEncodedPublicKey: String, with slaveSignature: Data) {
|
@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 master = DeviceLink.Device(hexEncodedPublicKey: masterHexEncodedPublicKey)
|
||||||
let slave = DeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
|
let slave = DeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
|
||||||
let deviceLink = DeviceLink(between: master, and: slave)
|
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) {
|
@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 master = DeviceLink.Device(hexEncodedPublicKey: masterHexEncodedPublicKey, signature: masterSignature)
|
||||||
let slave = DeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
|
let slave = DeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
|
||||||
let deviceLink = DeviceLink(between: master, and: slave)
|
let deviceLink = DeviceLink(between: master, and: slave)
|
||||||
|
|
|
@ -10,7 +10,7 @@ public final class LokiPublicChatPoller : NSObject {
|
||||||
private var pollForModeratorsTimer: Timer? = nil
|
private var pollForModeratorsTimer: Timer? = nil
|
||||||
private var pollForDisplayNamesTimer: Timer? = nil
|
private var pollForDisplayNamesTimer: Timer? = nil
|
||||||
private var hasStarted = false
|
private var hasStarted = false
|
||||||
private let userHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
private let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
|
|
||||||
// MARK: Settings
|
// MARK: Settings
|
||||||
private let pollForNewMessagesInterval: TimeInterval = 4
|
private let pollForNewMessagesInterval: TimeInterval = 4
|
||||||
|
|
|
@ -12,7 +12,7 @@ public final class LokiDatabaseUtilities : NSObject {
|
||||||
if let message = interaction as? TSIncomingMessage {
|
if let message = interaction as? TSIncomingMessage {
|
||||||
senderHexEncodedPublicKey = message.authorId
|
senderHexEncodedPublicKey = message.authorId
|
||||||
} else if let message = interaction as? TSOutgoingMessage {
|
} else if let message = interaction as? TSOutgoingMessage {
|
||||||
senderHexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
senderHexEncodedPublicKey = getUserHexEncodedPublicKey()
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public final class LokiDatabaseUtilities : NSObject {
|
||||||
|
|
||||||
@objc(isUserLinkedDevice:in:)
|
@objc(isUserLinkedDevice:in:)
|
||||||
public static func isUserLinkedDevice(_ hexEncodedPublicKey: String, transaction: YapDatabaseReadTransaction) -> Bool {
|
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)
|
let userLinkedDeviceHexEncodedPublicKeys = getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
|
||||||
return userLinkedDeviceHexEncodedPublicKeys.contains(hexEncodedPublicKey)
|
return userLinkedDeviceHexEncodedPublicKeys.contains(hexEncodedPublicKey)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ public final class DisplayNameUtilities : NSObject {
|
||||||
override private init() { }
|
override private init() { }
|
||||||
|
|
||||||
private static var userHexEncodedPublicKey: String {
|
private static var userHexEncodedPublicKey: String {
|
||||||
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
return getUserHexEncodedPublicKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var userDisplayName: String? {
|
private static var userDisplayName: String? {
|
||||||
|
|
4
SignalServiceKit/src/Loki/Utilities/General.swift
Normal file
4
SignalServiceKit/src/Loki/Utilities/General.swift
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
public func getUserHexEncodedPublicKey() -> String {
|
||||||
|
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
|
||||||
|
}
|
25
SignalServiceKit/src/Loki/Utilities/GroupUtilities.swift
Normal file
25
SignalServiceKit/src/Loki/Utilities/GroupUtilities.swift
Normal 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
|
||||||
|
}
|
||||||
|
}
|
|
@ -577,7 +577,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
[self handleProfileKeyUpdateIfNeeded:dataMessage recipientId:envelope.source];
|
[self handleProfileKeyUpdateIfNeeded:dataMessage recipientId:envelope.source];
|
||||||
|
|
||||||
|
|
||||||
if (dataMessage.group) {
|
if (dataMessage.group) {
|
||||||
TSGroupThread *_Nullable groupThread =
|
TSGroupThread *_Nullable groupThread =
|
||||||
[TSGroupThread threadWithGroupId:dataMessage.group.id transaction:transaction];
|
[TSGroupThread threadWithGroupId:dataMessage.group.id transaction:transaction];
|
||||||
|
|
Loading…
Reference in a new issue