diff --git a/Podfile b/Podfile index 0e3901e78b..1a8d29c48e 100644 --- a/Podfile +++ b/Podfile @@ -116,6 +116,7 @@ post_install do |installer| enable_extension_support_for_purelayout(installer) configure_warning_flags(installer) configure_testable_build(installer) + promote_minimum_supported_version(installer) disable_bitcode(installer) disable_armv7(installer) strip_valid_archs(installer) @@ -184,6 +185,24 @@ def configure_testable_build(installer) end end +# Xcode 13 dropped support for some older iOS versions. We only need them +# to support our project's minimum version, so let's bump each Pod's min +# version to our min to suppress these warnings. +def promote_minimum_supported_version(installer) + project_min_version = current_target_definition.platform.deployment_target + + installer.pods_project.targets.each do |target| + target.build_configurations.each do |build_configuration| + target_version_string = build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] + target_version = Version.create(target_version_string) + + if target_version < project_min_version + build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = project_min_version.version + end + end + end +end + def disable_bitcode(installer) installer.pods_project.targets.each do |target| diff --git a/Podfile.lock b/Podfile.lock index 3073b5fb7a..a9b83c0481 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -357,7 +357,7 @@ CHECKOUT OPTIONS: :commit: aaa24f6efae6114f1252ae86f02aeedc69a8b151 :git: https://github.com/signalapp/libsignal-client.git SignalCoreKit: - :commit: 83b856734ebec1483f36eee6ec710ad9908c197d + :commit: 04920eef158f9c3c88bc33fa75d9f18c3f2879e8 :git: "git@github.com:signalapp/SignalCoreKit" SignalMetadataKit: :commit: 90f1776e631e8e232360bbe11db620c77f078567 @@ -422,6 +422,6 @@ SPEC CHECKSUMS: YYImage: f1ddd15ac032a58b78bbed1e012b50302d318331 ZKGroup: 81ba58bf87b5614b03d49364db221390bf257dd7 -PODFILE CHECKSUM: 9f8a44c506114cbc5e155dea666f1d1cf48e4162 +PODFILE CHECKSUM: 2b9a3b19a25cb8362e446c82b27ac3533fe44793 COCOAPODS: 1.10.1 diff --git a/Pods b/Pods index 639f5b7e81..adfbc68ee6 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 639f5b7e810e08aa4198b47d8e785bce8811b317 +Subproject commit adfbc68ee60c53a119c6d736197c42f56245e9f1 diff --git a/Scripts/EmojiGenerator.swift b/Scripts/EmojiGenerator.swift index cbd3491706..b242512517 100755 --- a/Scripts/EmojiGenerator.swift +++ b/Scripts/EmojiGenerator.swift @@ -175,6 +175,8 @@ class EmojiGenerator { } static func generate() { + // This URL has been unavailable the past couple of weeks. If you're seeing failures here, try: + // https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json guard let jsonData = try? Data(contentsOf: URL(string: "https://unicodey.com/emoji-data/emoji.json")!) else { fatalError("Failed to download emoji-data json") } @@ -391,7 +393,7 @@ class EmojiGenerator { fileHandle.writeLine("extension Emoji {") // Value lookup per emoji - fileHandle.writeLine(" var name: String? {") + fileHandle.writeLine(" var name: String {") fileHandle.writeLine(" switch self {") for emojiData in sortedEmojiData { @@ -399,8 +401,6 @@ class EmojiGenerator { fileHandle.writeLine(" case .\(emojiData.enumName): return \"\(name)\"") } - fileHandle.writeLine(" default: return nil") - fileHandle.writeLine(" }") fileHandle.writeLine(" }") diff --git a/Scripts/sds_codegen/sds_generate.py b/Scripts/sds_codegen/sds_generate.py index 84b1980006..9368fddf66 100755 --- a/Scripts/sds_codegen/sds_generate.py +++ b/Scripts/sds_codegen/sds_generate.py @@ -1765,24 +1765,20 @@ public extension %(class_name)s { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 2ddc970507..66eb227b0b 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -7442,6 +7442,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; EXCLUDED_ARCHS = armv7; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/ThirdParty/WebRTC/Build"; + GCC_ENABLE_OBJC_EXCEPTIONS = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "TESTABLE_BUILD=1", @@ -7478,7 +7479,6 @@ ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "-DNS_BLOCK_ASSERTIONS=1", - "-fobjc-arc-exceptions", "-DTESTABLE_BUILDS", "-DNEW_CV_ARCHITECTURE", ); @@ -7582,6 +7582,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -7611,6 +7612,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -7795,6 +7800,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -7825,6 +7831,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -7856,6 +7866,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = s; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -7885,6 +7896,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -7917,6 +7932,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = s; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -7946,6 +7962,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -7995,6 +8015,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; EXCLUDED_ARCHS = armv7; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/ThirdParty/WebRTC/Build"; + GCC_ENABLE_OBJC_EXCEPTIONS = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = "TESTABLE_BUILD=1"; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; @@ -8026,10 +8047,7 @@ HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = YES; - OTHER_CFLAGS = ( - "-DNS_BLOCK_ASSERTIONS=1", - "-fobjc-arc-exceptions", - ); + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_SWIFT_FLAGS = "-DTESTABLE_BUILD"; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; @@ -8129,6 +8147,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -8158,6 +8177,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -8341,6 +8364,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = s; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -8370,6 +8394,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -8684,6 +8712,7 @@ ENABLE_TESTABILITY = YES; EXCLUDED_ARCHS = armv7; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/ThirdParty/WebRTC/Build"; + GCC_ENABLE_OBJC_EXCEPTIONS = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8720,7 +8749,6 @@ HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = YES; - OTHER_CFLAGS = "-fobjc-arc-exceptions"; OTHER_SWIFT_FLAGS = "-DTESTABLE_BUILD -DNEW_CV_ARCHITECTURE"; SDKROOT = iphoneos; SWIFT_VERSION = 4.0; @@ -8768,6 +8796,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; EXCLUDED_ARCHS = armv7; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/ThirdParty/WebRTC/Build"; + GCC_ENABLE_OBJC_EXCEPTIONS = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; @@ -8798,10 +8827,7 @@ HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 11.0; ONLY_ACTIVE_ARCH = NO; - OTHER_CFLAGS = ( - "-DNS_BLOCK_ASSERTIONS=1", - "-fobjc-arc-exceptions", - ); + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; @@ -8972,6 +8998,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -9002,6 +9029,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", @@ -9034,6 +9065,7 @@ "$(inherited)", "$(SRCROOT)", ); + GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_TEST_COVERAGE_FILES = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -9063,6 +9095,10 @@ "$(inherited)", "$(SRCROOT)", ); + OTHER_CFLAGS = ( + "$(inherited)", + "-fobjc-arc-exceptions", + ); OTHER_LDFLAGS = ( "-all_load", "-ObjC", diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 347daa1bef..cf53586463 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -794,8 +794,8 @@ void uncaughtExceptionHandler(NSException *exception) * create a document for your app to open using a URL. */ - (BOOL)application:(UIApplication *)application - continueUserActivity:(nonnull NSUserActivity *)userActivity - restorationHandler:(nonnull void (^)(NSArray *_Nullable))restorationHandler + continueUserActivity:(NSUserActivity *)userActivity + restorationHandler:(void (^)(NSArray> *_Nullable))restorationHandler { OWSAssertIsOnMainThread(); diff --git a/Signal/src/Models/OWSDeviceProvisioningURLParser.m b/Signal/src/Models/OWSDeviceProvisioningURLParser.m index d04831730a..63f7179fc7 100644 --- a/Signal/src/Models/OWSDeviceProvisioningURLParser.m +++ b/Signal/src/Models/OWSDeviceProvisioningURLParser.m @@ -26,10 +26,12 @@ NSString *const OWSQueryItemNameEncodedPublicKeyKey = @"pub_key"; _ephemeralDeviceId = queryItem.value; } else if ([queryItem.name isEqualToString:OWSQueryItemNameEncodedPublicKeyKey]) { NSString *encodedPublicKey = queryItem.value; - @try { - _publicKey = [[NSData dataFromBase64String:encodedPublicKey] throws_removeKeyType]; - } @catch (NSException *exception) { - OWSFailDebug(@"exception: %@", exception); + NSData *annotatedKey = [NSData dataFromBase64String:encodedPublicKey]; + + NSError *_Nullable error = nil; + _publicKey = [annotatedKey removeKeyTypeAndReturnError:&error]; + if (error) { + OWSFailDebug(@"failed to strip key type: %@", error); } } else { OWSLogWarn(@"Unknown query item in provisioning string: %@", queryItem.name); diff --git a/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift b/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift index 58f15e6c36..5d31be8371 100644 --- a/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift +++ b/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift @@ -241,15 +241,15 @@ final class ContactSupportViewController: OWSTableViewController2 { }.done(on: .main) { _ in self.navigationController?.presentingViewController?.dismiss(animated: true, completion: nil) + }.ensure(on: .main) { + self.currentEmailComposeOperation = nil + self.showSpinnerOnNextButton = false + }.catch(on: .main) { error in let alertTitle = error.userErrorDescription let alertMessage = NSLocalizedString("SUPPORT_EMAIL_ERROR_ALERT_DESCRIPTION", comment: "Message for alert dialog presented when a support email failed to send") OWSActionSheets.showActionSheet(title: alertTitle, message: alertMessage) - - }.ensure(on: .main) { - self.currentEmailComposeOperation = nil - self.showSpinnerOnNextButton = false } } } diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVColorOrGradientView.swift b/Signal/src/ViewControllers/ConversationView/CV/CVColorOrGradientView.swift index 12a128f7f1..ab549ce0bf 100644 --- a/Signal/src/ViewControllers/ConversationView/CV/CVColorOrGradientView.swift +++ b/Signal/src/ViewControllers/ConversationView/CV/CVColorOrGradientView.swift @@ -197,11 +197,8 @@ public class CVColorOrGradientView: ManualLayoutViewWithLayer { // coordinate space with lower-left origin. But the // observed behavior is that they use an upper-left origin. // I can't figure out why. - if false { - return CGPoint(x: point.x, y: (1 - point.y)) - } else { - return point - } + // return CGPoint(x: point.x, y: (1 - point.y)) + return point } // Control points within the local CALayer viewport. // Expressed as unit values with lower-left origin. diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVComponentDelegate.swift b/Signal/src/ViewControllers/ConversationView/CV/CVComponentDelegate.swift index 9f85c7309c..5a8c6f16c1 100644 --- a/Signal/src/ViewControllers/ConversationView/CV/CVComponentDelegate.swift +++ b/Signal/src/ViewControllers/ConversationView/CV/CVComponentDelegate.swift @@ -95,7 +95,7 @@ public protocol CVComponentDelegate { typealias EndCellAnimation = () -> Void func cvc_beginCellAnimation(maximumDuration: TimeInterval) -> EndCellAnimation - var view: UIView { get } + var view: UIView! { get } var isConversationPreview: Bool { get } diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVItemViewModelImpl.swift b/Signal/src/ViewControllers/ConversationView/CV/CVItemViewModelImpl.swift index 8649d3b742..97d774b0c2 100644 --- a/Signal/src/ViewControllers/ConversationView/CV/CVItemViewModelImpl.swift +++ b/Signal/src/ViewControllers/ConversationView/CV/CVItemViewModelImpl.swift @@ -195,7 +195,7 @@ extension CVItemViewModelImpl { } } - func shareMediaAction(sender: Any) { + func shareMediaAction(sender: Any?) { guard !isViewOnce else { return } diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVLoadRequest.swift b/Signal/src/ViewControllers/ConversationView/CV/CVLoadRequest.swift index 7f3154ae66..499f09b153 100644 --- a/Signal/src/ViewControllers/ConversationView/CV/CVLoadRequest.swift +++ b/Signal/src/ViewControllers/ConversationView/CV/CVLoadRequest.swift @@ -97,7 +97,7 @@ struct CVLoadRequest { function: String = #function, line: Int = #line) { if CVLoader.verboseLogging { - var logString = "\(label)[\(requestId)]. duration: \(loadStartDateFormatted), schedule delay: \(loadScheduleDelayIntervalFormatted)" + let logString = "\(label)[\(requestId)]. duration: \(loadStartDateFormatted), schedule delay: \(loadScheduleDelayIntervalFormatted)" Logger.info(logString, file: file, function: function, line: line) } } diff --git a/Signal/src/ViewControllers/ConversationView/CVViewState.swift b/Signal/src/ViewControllers/ConversationView/CVViewState.swift index ad27e3cca3..0f355e4002 100644 --- a/Signal/src/ViewControllers/ConversationView/CVViewState.swift +++ b/Signal/src/ViewControllers/ConversationView/CVViewState.swift @@ -550,9 +550,6 @@ public enum CVPresentationStatus: UInt, CustomStringConvertible { return ".firstViewDidAppearHasBegun" case .firstViewDidAppearHasCompleted: return ".firstViewDidAppearHasCompleted" - @unknown default: - owsFailDebug("unexpected value: \(self.rawValue)") - return "Unknown" } } } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.h b/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.h index 26ffd436e3..b78f2fe99b 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.h @@ -21,17 +21,4 @@ NS_ASSUME_NONNULL_BEGIN @end -#pragma mark - - -typedef void (^ObjCTryBlock)(void); -typedef void (^ObjCTryFailureBlock)(void); - -#pragma mark - - -@interface ObjCTry : NSObject - -+ (void)perform:(ObjCTryBlock)tryBlock failureBlock:(ObjCTryFailureBlock)failureBlock label:(NSString *)label; - -@end - NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.m b/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.m index 1e7ed56a51..d55b617852 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.m @@ -119,29 +119,4 @@ NS_ASSUME_NONNULL_BEGIN @end -#pragma mark - - -@implementation ObjCTry - -+ (void)perform:(ObjCTryBlock)tryBlock failureBlock:(ObjCTryFailureBlock)failureBlock label:(NSString *)label -{ - @try { - tryBlock(); - } @catch (NSException *exception) { - OWSLogError(@"Exception: %@.", label); - OWSLogError(@"Exception stack: %@.", exception.callStackSymbols); - OWSFailDebug(@"Exception: %@ of type: %@ with reason: %@, user info: %@.", - exception.description, - exception.name, - exception.reason, - exception.userInfo); - - failureBlock(); - - @throw exception; - } -} - -@end - NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.swift b/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.swift index cac65d01db..94a18b3095 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.swift +++ b/Signal/src/ViewControllers/ConversationView/ConversationCollectionView.swift @@ -3,100 +3,66 @@ // import Foundation +import SignalCoreKit public extension ConversationCollectionView { typealias CVCPerformBatchUpdatesBlock = () -> Void typealias CVCPerformBatchUpdatesCompletion = (Bool) -> Void - typealias CVCPerformBatchUpdatesFailure = () -> Void func cvc_reloadData(animated: Bool, cvc: ConversationViewController) { AssertIsOnMainThread() - ObjCTry.perform({ - cvc.layout.willReloadData() - if animated { + cvc.layout.willReloadData() + if animated { + super.reloadData() + } else { + UIView.performWithoutAnimation { super.reloadData() - } else { - UIView.performWithoutAnimation { - super.reloadData() - } } - cvc.layout.invalidateLayout() - cvc.layout.didReloadData() - }, failureBlock: { - Logger.warn("Render state: \(cvc.currentRenderStateDebugDescription)") - }) + } + cvc.layout.invalidateLayout() + cvc.layout.didReloadData() } func cvc_performBatchUpdates(_ batchUpdates: @escaping CVCPerformBatchUpdatesBlock, completion: @escaping CVCPerformBatchUpdatesCompletion, - failure: @escaping CVCPerformBatchUpdatesFailure, animated: Bool, scrollContinuity: ScrollContinuity, lastKnownDistanceFromBottom: CGFloat?, cvc: ConversationViewController) { AssertIsOnMainThread() - let tryFailure: ObjCTryFailureBlock = { - Logger.warn("Render state: \(cvc.currentRenderStateDebugDescription)") - failure() - } - let updateBlock = { - ObjCTry.perform({ - let layout = cvc.layout - layout.willPerformBatchUpdates(scrollContinuity: scrollContinuity, - lastKnownDistanceFromBottom: lastKnownDistanceFromBottom) - super.performBatchUpdates(batchUpdates) { (finished: Bool) in - AssertIsOnMainThread() + let layout = cvc.layout + layout.willPerformBatchUpdates(scrollContinuity: scrollContinuity, + lastKnownDistanceFromBottom: lastKnownDistanceFromBottom) + super.performBatchUpdates(batchUpdates) { (finished: Bool) in + AssertIsOnMainThread() - ObjCTry.perform({ - layout.didCompleteBatchUpdates() - - completion(finished) - }, failureBlock: tryFailure) - } - layout.didPerformBatchUpdates() - }, failureBlock: tryFailure) + layout.didCompleteBatchUpdates() + completion(finished) + } + layout.didPerformBatchUpdates() } - ObjCTry.perform({ - if animated { - updateBlock() - } else { - // HACK: We use `UIView.animateWithDuration:0` rather than `UIView.performWithAnimation` to work around a - // UIKit Crash like: - // - // *** Assertion failure in -[ConversationViewLayout prepareForCollectionViewUpdates:], - // /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UICollectionViewLayout.m:760 - // *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'While - // preparing update a visible view at {length = 2, path = 0 - 142} - // wasn't found in the current data model and was not in an update animation. This is an internal - // error.' - // - // I'm unclear if this is a bug in UIKit, or if we're doing something crazy in - // ConversationViewLayout#prepareLayout. To reproduce, rapidily insert and delete items into the - // conversation. See `DebugUIMessages#thrashCellsInThread:` - UIView.animate(withDuration: 0, animations: updateBlock) - } - }, failureBlock: tryFailure) - } -} - -// MARK: - - -extension ObjCTry { - public static func perform(_ tryBlock: @escaping ObjCTryBlock, - failureBlock: @escaping ObjCTryFailureBlock, - file: String = #file, - function: String = #function, - line: Int = #line) { - - let filename = (file as NSString).lastPathComponent - // We format the filename & line number in a format compatible - // with XCode's "Open Quickly..." feature. - let label = "[\(filename):\(line) \(function)]" - self.perform(tryBlock, failureBlock: failureBlock, label: label) + if animated { + updateBlock() + } else { + // HACK: We use `UIView.animateWithDuration:0` rather than `UIView.performWithAnimation` to work around a + // UIKit Crash like: + // + // *** Assertion failure in -[ConversationViewLayout prepareForCollectionViewUpdates:], + // /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UICollectionViewLayout.m:760 + // *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'While + // preparing update a visible view at {length = 2, path = 0 - 142} + // wasn't found in the current data model and was not in an update animation. This is an internal + // error.' + // + // I'm unclear if this is a bug in UIKit, or if we're doing something crazy in + // ConversationViewLayout#prepareLayout. To reproduce, rapidily insert and delete items into the + // conversation. See `DebugUIMessages#thrashCellsInThread:` + UIView.animate(withDuration: 0, animations: updateBlock) + } } } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVC.swift b/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVC.swift index bae9bf79b5..52e4004e3e 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVC.swift +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVC.swift @@ -640,19 +640,9 @@ extension ConversationViewController: CVLoadCoordinatorDelegate { } } - let logFailureBlock = { - for item in items { - Logger.warn("item: \(item.logSafeDescription)") - } - Logger.warn("Layout: \(self.layout.debugDescription)") - Logger.warn("prevRenderState: \(update.prevRenderState.debugDescription)") - Logger.warn("renderState: \(update.renderState.debugDescription)") - } - // We use an obj-c free function so that we can handle NSException. self.collectionView.cvc_performBatchUpdates(batchUpdatesBlock, completion: completion, - failure: logFailureBlock, animated: shouldAnimateUpdate, scrollContinuity: scrollContinuity, lastKnownDistanceFromBottom: updateToken.lastKnownDistanceFromBottom, diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController+Delegates.swift b/Signal/src/ViewControllers/ConversationView/ConversationViewController+Delegates.swift index 75733cefc3..784728c1f5 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController+Delegates.swift +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController+Delegates.swift @@ -319,19 +319,6 @@ extension ConversationViewController: ConversationSearchControllerDelegate { // MARK: - -extension ConversationViewController: UIDocumentMenuDelegate { - public func documentMenu(_ documentMenu: UIDocumentMenuViewController, - didPickDocumentPicker documentPicker: UIDocumentPickerViewController) { - AssertIsOnMainThread() - - documentPicker.delegate = self - dismissKeyBoard() - presentFormSheet(documentPicker, animated: true) - } -} - -// MARK: - - extension ConversationViewController: InputAccessoryViewPlaceholderDelegate { public func inputAccessoryPlaceholderKeyboardIsPresenting(animationDuration: TimeInterval, animationCurve: UIView.AnimationCurve) { diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIScreenshots.swift b/Signal/src/ViewControllers/DebugUI/DebugUIScreenshots.swift index 0dd05cc191..23ca2cdd73 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIScreenshots.swift +++ b/Signal/src/ViewControllers/DebugUI/DebugUIScreenshots.swift @@ -265,21 +265,29 @@ public extension DebugUIScreenshots { comment: "This is for a group of people interested in discussing books they've read."), avatarData: buildAvatarData(bundleFilename: "address-group-book.jpg"), transaction: transaction) - let timestampMessage1 = startingDateMS - (3 * kDayInMs + 4 * kHourInMs) - let message1 = self.buildOutgoingMessage(thread: thread, messageBody: NSLocalizedString("SCREENSHOT_THREAD_GROUP_ONE_MESSAGE_ONE", - comment: "This is for a message in the 'Book Club' group chat"), - timestamp: timestampMessage1, transaction: transaction) - let timestampMessage2 = startingDateMS - (3 * kDayInMs + 4 * kMinuteInMs) - let attachmentMessage2 = buildAttachment(bundleFilename: "1984.txt", - mimeType: "text/plain", - sourceFilename: NSLocalizedString("SCREENSHOT_THREAD_GROUP_ONE_FILE_NAME", - comment: "1984 is the book title. The file extension is a text file."), - transaction: transaction) - let message2 = self.buildOutgoingMessage(thread: thread, - messageBody: nil, - timestamp: timestampMessage2, - attachments: [attachmentMessage2], - transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_ONE_MESSAGE_ONE", + comment: "This is for a message in the 'Book Club' group chat"), + timestamp: startingDateMS - (3 * kDayInMs + 4 * kHourInMs), + transaction: transaction) + + let attachmentMessage2 = buildAttachment( + bundleFilename: "1984.txt", + mimeType: "text/plain", + sourceFilename: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_ONE_FILE_NAME", + comment: "1984 is the book title. The file extension is a text file."), + transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: nil, + timestamp: startingDateMS - (3 * kDayInMs + 4 * kMinuteInMs), + attachments: [attachmentMessage2], + transaction: transaction) } // Group incoming attachment + caption @@ -295,21 +303,30 @@ public extension DebugUIScreenshots { comment: "This is for a group chat for people who want weather updates."), avatarData: buildAvatarData(bundleFilename: "nature-2-trees.JPG"), transaction: transaction) - let timestampMessage1 = startingDateMS - (2 * kDayInMs + 8 * kHourInMs) - let message1 = self.buildOutgoingMessage(thread: thread, messageBody: NSLocalizedString("SCREENSHOT_THREAD_GROUP_TWO_MESSAGE_ONE", - comment: "This is a message. Please include the emoji if possible."), - timestamp: timestampMessage1, transaction: transaction) - let timestampMessage2 = startingDateMS - (2 * kDayInMs + 8 * kHourInMs + 1 * kMinuteInMs) - let attachmentMessage2 = buildAttachment(bundleFilename: "test-jpg-2.JPG", - mimeType: OWSMimeTypeImageJpeg, - transaction: transaction) - let message2 = self.buildIncomingMessage(thread: thread, - authorAddress: address9, - messageBody: NSLocalizedString("SCREENSHOT_THREAD_GROUP_TWO_MESSAGE_TWO", - comment: "This is a message sent with an attachment."), - timestamp: timestampMessage2, - attachments: [attachmentMessage2], - transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_TWO_MESSAGE_ONE", + comment: "This is a message. Please include the emoji if possible."), + timestamp: startingDateMS - (2 * kDayInMs + 8 * kHourInMs), + transaction: transaction) + + let attachmentMessage2 = buildAttachment( + bundleFilename: "test-jpg-2.JPG", + mimeType: OWSMimeTypeImageJpeg, + transaction: transaction) + + let message2 = buildIncomingMessage( + thread: thread, + authorAddress: address9, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_TWO_MESSAGE_TWO", + comment: "This is a message sent with an attachment."), + timestamp: startingDateMS - (2 * kDayInMs + 8 * kHourInMs + 1 * kMinuteInMs), + attachments: [attachmentMessage2], + transaction: transaction) + message2.debugonly_markAsReadNow(transaction: transaction) } @@ -368,20 +385,27 @@ public extension DebugUIScreenshots { comment: "Please include emoji. This is a group name/channel name for pictures of the sun in the sky."), avatarData: buildAvatarData(bundleFilename: "nature-4-sunset.jpg"), transaction: transaction) - let timestampMessage1 = startingDateMS - (1 * kDayInMs + 18 * kHourInMs) - let message1 = self.buildOutgoingMessage(thread: thread, messageBody: NSLocalizedString("SCREENSHOT_THREAD_GROUP_FOUR_MESSAGE_ONE", - comment: "This is a message in the Sunsets group chat."), - timestamp: timestampMessage1, transaction: transaction) - let timestampMessage2 = startingDateMS - (1 * kDayInMs + 18 * kHourInMs + 10 * kMinuteInMs) - let attachmentMessage2 = buildAttachment(bundleFilename: "nature-3-road.JPG", - mimeType: OWSMimeTypeImageJpeg, - transaction: transaction) - let message2 = self.buildOutgoingMessage(thread: thread, - messageBody: nil, - timestamp: timestampMessage2, - attachments: [attachmentMessage2], - isViewOnceMessage: true, - transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_FOUR_MESSAGE_ONE", + comment: "This is a message in the Sunsets group chat."), + timestamp: startingDateMS - (1 * kDayInMs + 18 * kHourInMs), + transaction: transaction) + + let attachmentMessage2 = buildAttachment( + bundleFilename: "nature-3-road.JPG", + mimeType: OWSMimeTypeImageJpeg, + transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: nil, + timestamp: startingDateMS - (1 * kDayInMs + 18 * kHourInMs + 10 * kMinuteInMs), + attachments: [attachmentMessage2], + isViewOnceMessage: true, + transaction: transaction) } // Example of how to make a simple 1:1 thread. @@ -393,15 +417,22 @@ public extension DebugUIScreenshots { let attachmentMessage1 = buildAttachment(bundleFilename: "test-jpg-3.JPG", mimeType: OWSMimeTypeImageJpeg, transaction: transaction) - let message1 = self.buildOutgoingMessage(thread: thread, - messageBody: nil, - timestamp: timestampMessage1, - attachments: [attachmentMessage1], transaction: transaction) - let timestampMessage2 = startingDateMS - (8 * kHourInMs + 27 * kMinuteInMs) - let message2 = self.buildOutgoingMessage(thread: thread, - messageBody: NSLocalizedString("SCREENSHOT_THREAD_DIRECT_FIVE_MESSAGE_ONE", - comment: "This is a message expressing support/happiness/awe/shock."), - timestamp: timestampMessage2, transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: nil, + timestamp: timestampMessage1, + attachments: [attachmentMessage1], + transaction: transaction) + + buildOutgoingMessage( + thread: thread, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_DIRECT_FIVE_MESSAGE_ONE", + comment: "This is a message expressing support/happiness/awe/shock."), + timestamp: startingDateMS - (8 * kHourInMs + 27 * kMinuteInMs), + transaction: transaction) + GroupManager.remoteUpdateDisappearingMessages(withContactOrV1GroupThread: thread, disappearingMessageToken: DisappearingMessageToken(isEnabled: true, durationSeconds: UInt32(24 * kHourInterval)), groupUpdateSourceAddress: localAddress, @@ -483,15 +514,21 @@ public extension DebugUIScreenshots { avatarData: buildAvatarData(bundleFilename: "address-group-family.jpg"), // avatarData: nil, transaction: transaction) - let message1 = self.buildOutgoingMessage(thread: thread, messageBody: NSLocalizedString("SCREENSHOT_THREAD_GROUP_FIVE_MESSAGE_ONE", - comment: "This is a message in the group chat of family members."), - transaction: transaction) - let timestampMessage2 = startingDateMS - (1 * kHourInMs + 58 * kMinuteInMs) - let message2 = self.buildIncomingMessage(thread: thread, - authorAddress: address6, - messageBody: NSLocalizedString("SCREENSHOT_THREAD_GROUP_FIVE_MESSAGE_TWO", - comment: "This is a message in the group chat of family members."), - timestamp: timestampMessage2, transaction: transaction) + buildOutgoingMessage( + thread: thread, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_FIVE_MESSAGE_ONE", + comment: "This is a message in the group chat of family members."), + transaction: transaction) + + buildIncomingMessage( + thread: thread, + authorAddress: address6, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_GROUP_FIVE_MESSAGE_TWO", + comment: "This is a message in the group chat of family members."), + timestamp: startingDateMS - (1 * kHourInMs + 58 * kMinuteInMs), + transaction: transaction) } // 1:1 sent media @@ -508,10 +545,11 @@ public extension DebugUIScreenshots { let attachmentMessage2 = buildAttachment(bundleFilename: "test-jpg-3.JPG", mimeType: OWSMimeTypeImageJpeg, transaction: transaction) - let message2 = self.buildOutgoingMessage(thread: thread, - messageBody: nil, - timestamp: timestampMessage2, - attachments: [attachmentMessage2], transaction: transaction) + buildOutgoingMessage( + thread: thread, + messageBody: nil, + timestamp: timestampMessage2, + attachments: [attachmentMessage2], transaction: transaction) } // Group other file types -- in focus @@ -525,12 +563,12 @@ public extension DebugUIScreenshots { // You can find files in the repo using something like this... // find . | grep -i "test-jpg" // ...where test-jpg is a partial file name. - let attachment1 = buildAttachment(bundleFilename: "test-jpg-2.JPG", - mimeType: OWSMimeTypeImageJpeg, - transaction: transaction) - let attachment2 = buildAttachment(bundleFilename: "test-jpg-2.JPG", - mimeType: OWSMimeTypeImageJpeg, - transaction: transaction) + buildAttachment(bundleFilename: "test-jpg-2.JPG", + mimeType: OWSMimeTypeImageJpeg, + transaction: transaction) + buildAttachment(bundleFilename: "test-jpg-2.JPG", + mimeType: OWSMimeTypeImageJpeg, + transaction: transaction) let memberAddresses = [ address1, @@ -617,13 +655,12 @@ public extension DebugUIScreenshots { let attachmentMessage7 = buildAttachment(bundleFilename: "test-jpg-3.JPG", mimeType: OWSMimeTypeImageJpeg, transaction: transaction) - let timestampMessage7 = startingDateMS - (9 * kMinuteInMs) - let message7 = self.buildOutgoingMessage(thread: thread, - messageBody: nil, - timestamp: timestampMessage7, - attachments: [attachmentMessage7], - isViewOnceMessage: true, - transaction: transaction) + buildOutgoingMessage(thread: thread, + messageBody: nil, + timestamp: startingDateMS - (9 * kMinuteInMs), + attachments: [attachmentMessage7], + isViewOnceMessage: true, + transaction: transaction) let attachmentMessage8 = buildAttachment(bundleFilename: "certificate.PDF", mimeType: "application/pdf", sourceFilename: NSLocalizedString("SCREENSHOT_THREAD_GROUP_SIX_FILE_NAME", comment: "This is a file name 'Instructions' for the cat chat group."), @@ -645,37 +682,40 @@ public extension DebugUIScreenshots { // you can fix that by saying: // _ = self.buildOutgoingMessage(...) let timestampMessage7 = startingDateMS - (4 * kMinuteInMs) - let message1 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "1", timestamp: timestampMessage7, transaction: transaction) - let message2 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "2", timestamp: timestampMessage7, transaction: transaction) - let message3 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "3", timestamp: timestampMessage7, transaction: transaction) - let message4 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "4.", timestamp: timestampMessage7, transaction: transaction) - let message5 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "5", timestamp: timestampMessage7, transaction: transaction) - let message6 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "6", timestamp: timestampMessage7, transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "1", timestamp: timestampMessage7, transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "2", timestamp: timestampMessage7, transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "3", timestamp: timestampMessage7, transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "4.", timestamp: timestampMessage7, transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "5", timestamp: timestampMessage7, transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: "6", timestamp: timestampMessage7, transaction: transaction) let attachmentMessage7 = buildAttachment(bundleFilename: "sonarping.mp3", mimeType: "audio/mp3", transaction: transaction) attachmentMessage7.attachmentType = .voiceMessage attachmentMessage7.anyOverwritingUpdate(transaction: transaction) - let message7 = self.buildIncomingMessage(thread: thread, - authorAddress: otherAddress, - messageBody: nil, - timestamp: timestampMessage7, - attachments: [attachmentMessage7], transaction: transaction) + buildIncomingMessage(thread: thread, authorAddress: otherAddress, messageBody: nil, timestamp: timestampMessage7, attachments: [attachmentMessage7], transaction: transaction) } // Second Thread -- Missed call or emoji on iPad if true { let otherAddress = address1 let thread = TSContactThread.getOrCreateThread(withContactAddress: otherAddress, transaction: transaction) - let timestampMessage1 = startingDateMS - (3 * kMinuteInMs) - let message1 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, - messageBody: "🤣🤣🤣", - timestamp: timestampMessage1, transaction: transaction) - let timestampMessage2 = startingDateMS - (2 * kMinuteInMs) - let message2 = self.buildIncomingMessage(thread: thread, authorAddress: otherAddress, - messageBody: NSLocalizedString("SCREENSHOT_THREAD_DIRECT_SEVEN_MESSAGE_ONE", comment: "This is a message before a call."), - timestamp: timestampMessage1, transaction: transaction) - let timestampCall1 = startingDateMS + buildIncomingMessage( + thread: thread, + authorAddress: otherAddress, + messageBody: "🤣🤣🤣", + timestamp: startingDateMS - (3 * kMinuteInMs), + transaction: transaction) + + buildIncomingMessage( + thread: thread, + authorAddress: otherAddress, + messageBody: NSLocalizedString( + "SCREENSHOT_THREAD_DIRECT_SEVEN_MESSAGE_ONE", + comment: "This is a message before a call."), + timestamp: startingDateMS - (2 * kMinuteInMs), + transaction: transaction) + // Replace .incomingIncomplete with other values to create other record types. // Note that you have to remove the obj-c enum prefix. // @@ -1007,6 +1047,7 @@ public extension DebugUIScreenshots { emails: []) } + @discardableResult private class func buildOutgoingMessage(thread: TSThread, messageBody: String?, timestamp: UInt64? = nil, @@ -1063,6 +1104,7 @@ public extension DebugUIScreenshots { return message } + @discardableResult private class func buildIncomingMessage(thread: TSThread, authorAddress: SignalServiceAddress, messageBody: String?, @@ -1099,6 +1141,7 @@ public extension DebugUIScreenshots { return try! Data(contentsOf: fileUrl) } + @discardableResult private class func buildAttachment(bundleFilename: String, mimeType: String, sourceFilename: String? = nil, diff --git a/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m b/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m index 809a7c7a3d..e6922d7bde 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN NSMutableData *flippedKey = [NSMutableData new]; const char *currentKeyBytes = currentKey.bytes; for (NSUInteger i = 0; i < currentKey.length; i++) { - const char xorByte = currentKeyBytes[i] ^ 0xff; + const char xorByte = currentKeyBytes[i] ^ (char)0xff; [flippedKey appendBytes:&xorByte length:1]; } OWSAssertDebug(flippedKey.length == currentKey.length); diff --git a/Signal/src/ViewControllers/HomeView/HVTableDataSource.swift b/Signal/src/ViewControllers/HomeView/HVTableDataSource.swift index 90d6d142ef..cbd11eeb89 100644 --- a/Signal/src/ViewControllers/HomeView/HVTableDataSource.swift +++ b/Signal/src/ViewControllers/HomeView/HVTableDataSource.swift @@ -979,6 +979,5 @@ public class HVTableView: UITableView { @available(*, unavailable, message: "use other constructor instead.") required init?(coder: NSCoder) { notImplemented() - fatalError("init(coder:) has not been implemented") } } diff --git a/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift b/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift index 97009782c8..44a6ec0e2d 100644 --- a/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift +++ b/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift @@ -10,7 +10,7 @@ class MediaDismissAnimationController: NSObject { var transitionView: UIView? var fromMediaFrame: CGRect? - var pendingCompletion: (() -> Promise)? + var pendingCompletion: (() -> Void)? init(galleryItem: MediaGalleryItem, interactionController: MediaInteractiveDismiss? = nil) { self.item = .gallery(galleryItem) @@ -149,8 +149,7 @@ extension MediaDismissAnimationController: UIViewControllerAnimatedTransitioning let duration = transitionDuration(using: transitionContext) - let completion = { () -> Promise in - + let completion = { let destinationFrame: CGRect let destinationCornerRadius: CGFloat if transitionContext.transitionWasCancelled { @@ -168,7 +167,7 @@ extension MediaDismissAnimationController: UIViewControllerAnimatedTransitioning destinationCornerRadius = fromMediaContext.cornerRadius } - return UIView.animate(.promise, + UIView.animate(.promise, duration: duration, delay: 0.0, options: [.beginFromCurrentState, .curveEaseInOut]) { @@ -215,15 +214,15 @@ extension MediaDismissAnimationController: UIViewControllerAnimatedTransitioning options: [.beginFromCurrentState, .curveEaseInOut]) { fromTransitionalOverlayView?.alpha = 0.0 fromView.alpha = 0.0 - }.then { (_: Bool) -> Promise in + }.done { _ in guard let pendingCompletion = self.pendingCompletion else { Logger.verbose("pendingCompletion already ran by the time fadeout completed.") - return Promise.value(()) + return } Logger.verbose("ran pendingCompletion after fadeout") self.pendingCompletion = nil - return pendingCompletion() + pendingCompletion() } } } @@ -250,7 +249,7 @@ extension MediaDismissAnimationController: InteractiveDismissDelegate { if let pendingCompletion = pendingCompletion { Logger.verbose("interactive gesture started pendingCompletion during fadeout") self.pendingCompletion = nil - _ = pendingCompletion() + pendingCompletion() } } diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index ed02d7463a..e18e484407 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -1072,7 +1072,6 @@ private class AnimationController: NSObject, UIViewControllerAnimatedTransitioni let bottomView: UIView let isPushing = operation == .push - let isInteractive = percentDrivenTransition != nil if isPushing { topView = fromView diff --git a/Signal/src/ViewControllers/Photos/PhotoCapture.swift b/Signal/src/ViewControllers/Photos/PhotoCapture.swift index ca1dc02a3e..1dacfbfc20 100644 --- a/Signal/src/ViewControllers/Photos/PhotoCapture.swift +++ b/Signal/src/ViewControllers/Photos/PhotoCapture.swift @@ -963,7 +963,7 @@ class CaptureOutput: NSObject { videoInput.expectsMediaDataInRealTime = true assetWriter.add(videoInput) - let audioSettings: [String: Any]? = self.audioDataOutput.recommendedAudioSettingsForAssetWriter(writingTo: .mp4) as? [String: Any] + let audioSettings: [String: Any]? = self.audioDataOutput.recommendedAudioSettingsForAssetWriter(writingTo: .mp4) let audioInput = AVAssetWriterInput(mediaType: .audio, outputSettings: audioSettings) audioInput.expectsMediaDataInRealTime = true if audioSettings != nil { diff --git a/Signal/src/ViewControllers/Registration/OnboardingController.swift b/Signal/src/ViewControllers/Registration/OnboardingController.swift index 0ffb613b53..db4d25dffa 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingController.swift @@ -743,8 +743,13 @@ public class OnboardingController: NSObject { self.kbsAuth = nil if self.hasPendingRestoration { - self.accountManager.performInitialStorageServiceRestore() - .ensure { completion(.success) } + firstly { + self.accountManager.performInitialStorageServiceRestore() + }.recover { error in + Logger.warn("Timed out performing storage service restore: \(error). Ignoring...") + }.done { + completion(.success) + } } else { // We've restored our keys, we can now re-run this method to post our registration token diff --git a/Signal/src/util/Device Transfer/DeviceTransferService+MultipeerDelegates.swift b/Signal/src/util/Device Transfer/DeviceTransferService+MultipeerDelegates.swift index 76976218c3..2bf30d86c0 100644 --- a/Signal/src/util/Device Transfer/DeviceTransferService+MultipeerDelegates.swift +++ b/Signal/src/util/Device Transfer/DeviceTransferService+MultipeerDelegates.swift @@ -157,17 +157,17 @@ extension DeviceTransferService: MCSessionDelegate { owsFail("Restore failed. Will try again on next launch. Error: \(error)") } - firstly(on: .main) { () -> Promise in + firstly(on: .main) { () -> Guarantee in // A successful restoration means we've updated our database path. // Extensions will learn of this through NSUserDefaults KVO and exit ASAP self.databaseStorage.reloadDatabase() - }.then(on: .main) { () -> Promise in + }.then(on: .main) { () -> Guarantee in self.finalizeRestorationIfNecessary() }.done(on: .main) { // After transfer our push token has changed, update it. SyncPushTokensJob.run() SignalApp.shared().showConversationSplitView() - }.cauterize() // TODO: Everything in this promise chain is a guarantee. + } stopTransfer() } diff --git a/Signal/src/util/Device Transfer/DeviceTransferService+Restore.swift b/Signal/src/util/Device Transfer/DeviceTransferService+Restore.swift index 7a698a510d..9f88c33c94 100644 --- a/Signal/src/util/Device Transfer/DeviceTransferService+Restore.swift +++ b/Signal/src/util/Device Transfer/DeviceTransferService+Restore.swift @@ -354,8 +354,7 @@ extension DeviceTransferService { success = true } if success { - // TODO: This should return a guarantee - finalizeRestorationIfNecessary().cauterize() + finalizeRestorationIfNecessary() } return success } @@ -542,10 +541,11 @@ extension DeviceTransferService { GRDBDatabaseStorageAdapter.promoteTransferDirectoryToPrimary() } - func finalizeRestorationIfNecessary() -> Promise { + @discardableResult + func finalizeRestorationIfNecessary() -> Guarantee { resetTransferDirectory() - let (promise, future) = Promise.pending() + let (promise, future) = Guarantee.pending() AppReadiness.runNowOrWhenAppDidBecomeReadySync { self.tsAccountManager.isTransferInProgress = false diff --git a/Signal/src/util/Emoji/Emoji+Name.swift b/Signal/src/util/Emoji/Emoji+Name.swift index 56d1d33661..e9cc21ef88 100644 --- a/Signal/src/util/Emoji/Emoji+Name.swift +++ b/Signal/src/util/Emoji/Emoji+Name.swift @@ -5,7 +5,7 @@ // This file is generated by EmojiGenerator.swift, do not manually edit it. extension Emoji { - var name: String? { + var name: String { switch self { case .grinning: return "GRINNING FACE" case .smiley: return "SMILING FACE WITH OPEN MOUTH" @@ -1824,7 +1824,6 @@ extension Emoji { case .flagEngland: return "England Flag" case .flagScotland: return "Scotland Flag" case .flagWales: return "Wales Flag" - default: return nil } } } diff --git a/SignalMessaging/Payments/PaymentsProcessor.swift b/SignalMessaging/Payments/PaymentsProcessor.swift index e2d06eebb2..2ed14a6e8b 100644 --- a/SignalMessaging/Payments/PaymentsProcessor.swift +++ b/SignalMessaging/Payments/PaymentsProcessor.swift @@ -126,8 +126,6 @@ public class PaymentsProcessor: NSObject { transaction: transaction) } - let intervalSinceLaunch = abs(CurrentAppContext().appLaunchTime.timeIntervalSinceNow) - paymentModels.sort { (left, right) -> Bool in left.sortDate.compare(right.sortDate) == .orderedAscending } diff --git a/SignalMessaging/contacts/OWSSyncManager.h b/SignalMessaging/contacts/OWSSyncManager.h index 9a95516e02..24df0b617a 100644 --- a/SignalMessaging/contacts/OWSSyncManager.h +++ b/SignalMessaging/contacts/OWSSyncManager.h @@ -2,6 +2,8 @@ // Copyright (c) 2021 Open Whisper Systems. All rights reserved. // +#import + NS_ASSUME_NONNULL_BEGIN extern NSString *const OWSSyncManagerConfigurationSyncDidCompleteNotification; diff --git a/SignalMessaging/groups/GroupsV2Migration.swift b/SignalMessaging/groups/GroupsV2Migration.swift index b04fa6e255..0a224ddd48 100644 --- a/SignalMessaging/groups/GroupsV2Migration.swift +++ b/SignalMessaging/groups/GroupsV2Migration.swift @@ -49,7 +49,7 @@ public extension GroupsV2Migration { // the service. static func tryToMigrate(groupThread: TSGroupThread, migrationMode: GroupsV2MigrationMode) -> Promise { - firstly(on: .global()) { + firstly(on: .global()) { () -> Bool in if migrationMode == .isAlreadyMigratedOnService || migrationMode == .possiblyAlreadyMigratedOnService { return true diff --git a/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration+SDS.swift b/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration+SDS.swift index 985cb7ec3d..aa232e506a 100644 --- a/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration+SDS.swift +++ b/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration+SDS.swift @@ -486,24 +486,20 @@ public extension OWSDisappearingMessagesConfiguration { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Contacts/SignalAccount+SDS.swift b/SignalServiceKit/src/Contacts/SignalAccount+SDS.swift index 0e6c7255cf..44cad32a5e 100644 --- a/SignalServiceKit/src/Contacts/SignalAccount+SDS.swift +++ b/SignalServiceKit/src/Contacts/SignalAccount+SDS.swift @@ -537,24 +537,20 @@ public extension SignalAccount { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Contacts/SignalRecipient+SDS.swift b/SignalServiceKit/src/Contacts/SignalRecipient+SDS.swift index 50b8de04b4..a2ae33e66f 100644 --- a/SignalServiceKit/src/Contacts/SignalRecipient+SDS.swift +++ b/SignalServiceKit/src/Contacts/SignalRecipient+SDS.swift @@ -500,24 +500,20 @@ public extension SignalRecipient { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Contacts/TSGroupMember+SDS.swift b/SignalServiceKit/src/Contacts/TSGroupMember+SDS.swift index 143bd21d5d..3679cdd49f 100644 --- a/SignalServiceKit/src/Contacts/TSGroupMember+SDS.swift +++ b/SignalServiceKit/src/Contacts/TSGroupMember+SDS.swift @@ -504,24 +504,20 @@ public extension TSGroupMember { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Contacts/TSThread+SDS.swift b/SignalServiceKit/src/Contacts/TSThread+SDS.swift index a2632d1295..6578c1fb0a 100644 --- a/SignalServiceKit/src/Contacts/TSThread+SDS.swift +++ b/SignalServiceKit/src/Contacts/TSThread+SDS.swift @@ -825,24 +825,20 @@ public extension TSThread { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Devices/OWSDevice+SDS.swift b/SignalServiceKit/src/Devices/OWSDevice+SDS.swift index e1f306db61..098a8802ab 100644 --- a/SignalServiceKit/src/Devices/OWSDevice+SDS.swift +++ b/SignalServiceKit/src/Devices/OWSDevice+SDS.swift @@ -506,24 +506,20 @@ public extension OWSDevice { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachment+SDS.swift b/SignalServiceKit/src/Messages/Attachments/TSAttachment+SDS.swift index 1c77457638..d9a8b6b76e 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachment+SDS.swift +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachment+SDS.swift @@ -862,24 +862,20 @@ public extension TSAttachment { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction+SDS.swift b/SignalServiceKit/src/Messages/Interactions/TSInteraction+SDS.swift index cd5ca164f1..f707735325 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction+SDS.swift +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction+SDS.swift @@ -4361,24 +4361,20 @@ public extension TSInteraction { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Interactions/TSMention+SDS.swift b/SignalServiceKit/src/Messages/Interactions/TSMention+SDS.swift index bb71cb3b3c..7cceadf8fc 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSMention+SDS.swift +++ b/SignalServiceKit/src/Messages/Interactions/TSMention+SDS.swift @@ -505,24 +505,20 @@ public extension TSMention { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/MessageSender.m b/SignalServiceKit/src/Messages/MessageSender.m index c16dbb7b6b..aca7e11f9e 100644 --- a/SignalServiceKit/src/Messages/MessageSender.m +++ b/SignalServiceKit/src/Messages/MessageSender.m @@ -42,7 +42,6 @@ #import "TSThread.h" #import #import -#import #import #import #import diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m index afe1ab0f1f..8f2c5740b2 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m @@ -227,7 +227,7 @@ void AssertIsOnDisappearingMessagesQueue() dispatch_once(&onceToken, ^{ dateFormatter = [NSDateFormatter new]; dateFormatter.dateStyle = NSDateFormatterNoStyle; - dateFormatter.timeStyle = kCFDateFormatterMediumStyle; + dateFormatter.timeStyle = NSDateFormatterMediumStyle; dateFormatter.locale = [NSLocale systemLocale]; }); diff --git a/SignalServiceKit/src/Messages/OWSMessageContentJob+SDS.swift b/SignalServiceKit/src/Messages/OWSMessageContentJob+SDS.swift index e2b6b8201b..5c2a31b544 100644 --- a/SignalServiceKit/src/Messages/OWSMessageContentJob+SDS.swift +++ b/SignalServiceKit/src/Messages/OWSMessageContentJob+SDS.swift @@ -514,24 +514,20 @@ public extension OWSMessageContentJob { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/OWSMessageDecryptJob+SDS.swift b/SignalServiceKit/src/Messages/OWSMessageDecryptJob+SDS.swift index ba356a1df2..b2e6780d12 100644 --- a/SignalServiceKit/src/Messages/OWSMessageDecryptJob+SDS.swift +++ b/SignalServiceKit/src/Messages/OWSMessageDecryptJob+SDS.swift @@ -496,24 +496,20 @@ public extension OWSMessageDecryptJob { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Reactions/OWSReaction+SDS.swift b/SignalServiceKit/src/Messages/Reactions/OWSReaction+SDS.swift index e49aae9c6d..ae8a5f315a 100644 --- a/SignalServiceKit/src/Messages/Reactions/OWSReaction+SDS.swift +++ b/SignalServiceKit/src/Messages/Reactions/OWSReaction+SDS.swift @@ -531,24 +531,20 @@ public extension OWSReaction { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Stickers/InstalledSticker+SDS.swift b/SignalServiceKit/src/Messages/Stickers/InstalledSticker+SDS.swift index fb8bdc1cd3..66d6b67abd 100644 --- a/SignalServiceKit/src/Messages/Stickers/InstalledSticker+SDS.swift +++ b/SignalServiceKit/src/Messages/Stickers/InstalledSticker+SDS.swift @@ -514,24 +514,20 @@ public extension InstalledSticker { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Stickers/KnownStickerPack+SDS.swift b/SignalServiceKit/src/Messages/Stickers/KnownStickerPack+SDS.swift index 466e3e2113..4ba748573f 100644 --- a/SignalServiceKit/src/Messages/Stickers/KnownStickerPack+SDS.swift +++ b/SignalServiceKit/src/Messages/Stickers/KnownStickerPack+SDS.swift @@ -499,24 +499,20 @@ public extension KnownStickerPack { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Messages/Stickers/StickerPack+SDS.swift b/SignalServiceKit/src/Messages/Stickers/StickerPack+SDS.swift index 4a0a7554b6..852d61a164 100644 --- a/SignalServiceKit/src/Messages/Stickers/StickerPack+SDS.swift +++ b/SignalServiceKit/src/Messages/Stickers/StickerPack+SDS.swift @@ -541,24 +541,20 @@ public extension StickerPack { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Network/Receiving/IncomingGroupsV2MessageJob+SDS.swift b/SignalServiceKit/src/Network/Receiving/IncomingGroupsV2MessageJob+SDS.swift index be4fb8e231..36618b1002 100644 --- a/SignalServiceKit/src/Network/Receiving/IncomingGroupsV2MessageJob+SDS.swift +++ b/SignalServiceKit/src/Network/Receiving/IncomingGroupsV2MessageJob+SDS.swift @@ -523,24 +523,20 @@ public extension IncomingGroupsV2MessageJob { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Payments/TSPaymentModel+SDS.swift b/SignalServiceKit/src/Payments/TSPaymentModel+SDS.swift index 2201aba2c3..1a6d728013 100644 --- a/SignalServiceKit/src/Payments/TSPaymentModel+SDS.swift +++ b/SignalServiceKit/src/Payments/TSPaymentModel+SDS.swift @@ -611,24 +611,20 @@ public extension TSPaymentModel { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Payments/TSPaymentRequestModel+SDS.swift b/SignalServiceKit/src/Payments/TSPaymentRequestModel+SDS.swift index fe5feaf110..cb0fa57e4a 100644 --- a/SignalServiceKit/src/Payments/TSPaymentRequestModel+SDS.swift +++ b/SignalServiceKit/src/Payments/TSPaymentRequestModel+SDS.swift @@ -525,24 +525,20 @@ public extension TSPaymentRequestModel { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Remote Attestation/RemoteAttestationSigningCertificate.m b/SignalServiceKit/src/Remote Attestation/RemoteAttestationSigningCertificate.m index c6e6a0bc53..c9ca1a3008 100644 --- a/SignalServiceKit/src/Remote Attestation/RemoteAttestationSigningCertificate.m +++ b/SignalServiceKit/src/Remote Attestation/RemoteAttestationSigningCertificate.m @@ -384,7 +384,7 @@ NSError *RemoteAttestationSigningCertificateErrorMake(RemoteAttestationSigningCe return nil; } - unsigned char *entryName = ASN1_STRING_data(entryData); + const unsigned char *entryName = ASN1_STRING_get0_data(entryData); if (entryName == NULL) { OWSFailDebug(@"could not extract entry string."); return nil; diff --git a/SignalServiceKit/src/Security/OWSRecipientIdentity+SDS.swift b/SignalServiceKit/src/Security/OWSRecipientIdentity+SDS.swift index 4e1f7c7aa8..1a93bcdd08 100644 --- a/SignalServiceKit/src/Security/OWSRecipientIdentity+SDS.swift +++ b/SignalServiceKit/src/Security/OWSRecipientIdentity+SDS.swift @@ -514,24 +514,20 @@ public extension OWSRecipientIdentity { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Storage/Database/SDSDatabaseStorage.swift b/SignalServiceKit/src/Storage/Database/SDSDatabaseStorage.swift index 28519a67b7..86c858a898 100644 --- a/SignalServiceKit/src/Storage/Database/SDSDatabaseStorage.swift +++ b/SignalServiceKit/src/Storage/Database/SDSDatabaseStorage.swift @@ -138,8 +138,7 @@ public class SDSDatabaseStorage: SDSTransactable { } } - // TODO: This should return a guarantee - public func reloadDatabase() -> Promise { + public func reloadDatabase() -> Guarantee { AssertIsOnMainThread() assert(storageCoordinatorState == .GRDB) @@ -147,7 +146,7 @@ public class SDSDatabaseStorage: SDSTransactable { let wasRegistered = TSAccountManager.shared.isRegistered - let (promise, future) = Promise.pending() + let (promise, future) = Guarantee.pending() reopenGRDBStorage { _ = GRDBSchemaMigrator().runSchemaMigrations() diff --git a/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift b/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift index b70cb4a4cf..bb4b3e3a6a 100644 --- a/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift +++ b/SignalServiceKit/src/Storage/Database/SDSKeyValueStore.swift @@ -365,7 +365,7 @@ public class SDSKeyValueStore: NSObject { @objc public func allValues(transaction: SDSAnyReadTransaction) -> [Any] { - return allKeys(transaction: transaction).map { key in + return allKeys(transaction: transaction).compactMap { key in return self.read(key, transaction: transaction) } } diff --git a/SignalServiceKit/src/Storage/Jobs/SSKJobRecord+SDS.swift b/SignalServiceKit/src/Storage/Jobs/SSKJobRecord+SDS.swift index a644129584..14d9f827ed 100644 --- a/SignalServiceKit/src/Storage/Jobs/SSKJobRecord+SDS.swift +++ b/SignalServiceKit/src/Storage/Jobs/SSKJobRecord+SDS.swift @@ -855,24 +855,20 @@ public extension SSKJobRecord { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Util/ExperienceUpgrade+SDS.swift b/SignalServiceKit/src/Util/ExperienceUpgrade+SDS.swift index 81821a0970..1b7a19c907 100644 --- a/SignalServiceKit/src/Util/ExperienceUpgrade+SDS.swift +++ b/SignalServiceKit/src/Util/ExperienceUpgrade+SDS.swift @@ -495,24 +495,20 @@ public extension ExperienceUpgrade { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Util/OWSBackupFragment+SDS.swift b/SignalServiceKit/src/Util/OWSBackupFragment+SDS.swift index 71646bf261..9eb36663d7 100644 --- a/SignalServiceKit/src/Util/OWSBackupFragment+SDS.swift +++ b/SignalServiceKit/src/Util/OWSBackupFragment+SDS.swift @@ -522,24 +522,20 @@ public extension OWSBackupFragment { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Util/OWSUserProfile+SDS.swift b/SignalServiceKit/src/Util/OWSUserProfile+SDS.swift index 3e61a492f3..aa9d355c92 100644 --- a/SignalServiceKit/src/Util/OWSUserProfile+SDS.swift +++ b/SignalServiceKit/src/Util/OWSUserProfile+SDS.swift @@ -602,24 +602,20 @@ public extension OWSUserProfile { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalServiceKit/src/Util/TestModel+SDS.swift b/SignalServiceKit/src/Util/TestModel+SDS.swift index 9c41ff0356..8e15651f41 100644 --- a/SignalServiceKit/src/Util/TestModel+SDS.swift +++ b/SignalServiceKit/src/Util/TestModel+SDS.swift @@ -550,24 +550,20 @@ public extension TestModel { let uniqueIds = anyAllUniqueIds(transaction: transaction) var index: Int = 0 - do { - try Batching.loop(batchSize: Batching.kDefaultBatchSize, - loopBlock: { stop in - guard index < uniqueIds.count else { - stop.pointee = true - return - } - let uniqueId = uniqueIds[index] - index = index + 1 - guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { - owsFailDebug("Missing instance.") - return - } - instance.anyRemove(transaction: transaction) - }) - } catch { - owsFailDebug("Error: \(error)") - } + Batching.loop(batchSize: Batching.kDefaultBatchSize, + loopBlock: { stop in + guard index < uniqueIds.count else { + stop.pointee = true + return + } + let uniqueId = uniqueIds[index] + index = index + 1 + guard let instance = anyFetch(uniqueId: uniqueId, transaction: transaction) else { + owsFailDebug("Missing instance.") + return + } + instance.anyRemove(transaction: transaction) + }) if shouldBeIndexedForFTS { FullTextSearchFinder.allModelsWereRemoved(collection: collection(), transaction: transaction) diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index cf1b019ab4..bf2c7328bd 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -708,9 +708,6 @@ public class ShareViewController: UIViewController, ShareViewDelegate, SAEFailed return "pdf" case .pkPass: return "pkPass" - @unknown default: - owsFailDebug("Unknown value.") - return "unknown" } } } diff --git a/SignalUI/Appearance/ColorOrGradientSwatchView.swift b/SignalUI/Appearance/ColorOrGradientSwatchView.swift index 51bdd97b43..d6c29b3cfb 100644 --- a/SignalUI/Appearance/ColorOrGradientSwatchView.swift +++ b/SignalUI/Appearance/ColorOrGradientSwatchView.swift @@ -141,11 +141,9 @@ public class ColorOrGradientSwatchView: ManualLayoutViewWithLayer { // coordinate space with lower-left origin. But the // observed behavior is that they use an upper-left origin. // I can't figure out why. - if false { - return CGPoint(x: point.x, y: (1 - point.y)) - } else { - return point - } + // + // return CGPoint(x: point.x, y: (1 - point.y)) + return point } let startPointLL = convertToLayerUnit(startPointUL) let endPointLL = convertToLayerUnit(endPointUL) diff --git a/SignalUI/Categories/UIView+SignalUI.m b/SignalUI/Categories/UIView+SignalUI.m index 7782e8600b..7d42a3cd5f 100644 --- a/SignalUI/Categories/UIView+SignalUI.m +++ b/SignalUI/Categories/UIView+SignalUI.m @@ -591,7 +591,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) hairlineView.backgroundColor = color; [hairlineView autoSetDimension:ALDimensionHeight toSize:1]; - [self insertArrangedSubview:hairlineView atIndex:(NSInteger)index]; + [self insertArrangedSubview:hairlineView atIndex:(NSUInteger)index]; } - (UIView *)addBackgroundViewWithBackgroundColor:(UIColor *)backgroundColor