diff --git a/SignalServiceKit/src/Loki/Protocol/Multi Device/DeviceLink.swift b/SignalServiceKit/src/Loki/Protocol/Multi Device/DeviceLink.swift index 7241826a8..eb62f62e1 100644 --- a/SignalServiceKit/src/Loki/Protocol/Multi Device/DeviceLink.swift +++ b/SignalServiceKit/src/Loki/Protocol/Multi Device/DeviceLink.swift @@ -11,7 +11,7 @@ public final class DeviceLink : NSObject, NSCoding { return (userHexEncodedPublicKey == master.hexEncodedPublicKey) ? slave : master } - // MARK: Nested Types + // MARK: Device @objc(LKDevice) public final class Device : NSObject, NSCoding { @objc public let hexEncodedPublicKey: String diff --git a/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift index 7d01bd7e9..0d73b8f51 100644 --- a/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift @@ -20,15 +20,15 @@ public final class SyncMessagesProtocol : NSObject { // MARK: - Sending @objc(shouldSkipConfigurationSyncMessage) public static func shouldSkipConfigurationSyncMessage() -> Bool { + // FIXME: We added this check to avoid a crash, but we should really figure out why that crash was happening in the first place return !UserDefaults.standard[.hasLaunchedOnce] } @objc(syncContactWithHexEncodedPublicKey:in:) public static func syncContact(_ hexEncodedPublicKey: String, in transaction: YapDatabaseReadTransaction) { - if let thread = TSContactThread.getWithContactId(hexEncodedPublicKey, transaction: transaction) { // TODO: Should this be getOrCreate? - let syncManager = SSKEnvironment.shared.syncManager - syncManager.syncContacts(for: [ SignalAccount(recipientId: hexEncodedPublicKey) ]) - } + guard TSContactThread.getWithContactId(hexEncodedPublicKey, transaction: transaction) != nil else { return } + let syncManager = SSKEnvironment.shared.syncManager + syncManager.syncContacts(for: [ SignalAccount(recipientId: hexEncodedPublicKey) ]) } @objc(syncAllContacts) @@ -46,7 +46,7 @@ public final class SyncMessagesProtocol : NSObject { } friends.append(SignalAccount(recipientId: getUserHexEncodedPublicKey())) // TODO: We sure about this? let syncManager = SSKEnvironment.shared.syncManager - let promises = friends.chunked(by: 3).map { friends -> Promise in + let promises = friends.chunked(by: 3).map { friends -> Promise in // TODO: Does this always fit? return Promise(syncManager.syncContacts(for: friends)).map { _ in } } return when(fulfilled: promises) @@ -60,7 +60,8 @@ public final class SyncMessagesProtocol : NSObject { public static func syncAllClosedGroups() -> Promise { var groups: [TSGroupThread] = [] TSGroupThread.enumerateCollectionObjects { object, _ in - guard let group = object as? TSGroupThread, group.groupModel.groupType == .closedGroup, group.shouldThreadBeVisible, !group.isForceHidden else { return } + guard let group = object as? TSGroupThread, group.groupModel.groupType == .closedGroup, + group.shouldThreadBeVisible, !group.isForceHidden else { return } groups.append(group) } let syncManager = SSKEnvironment.shared.syncManager @@ -81,9 +82,9 @@ public final class SyncMessagesProtocol : NSObject { let messageSender = SSKEnvironment.shared.messageSender messageSender.send(openGroupSyncMessage, success: { seal.fulfill(()) - }) { error in + }, failure: { error in seal.reject(error) - } + }) return promise }