From 4cf438d740c890ddff69439e987a554c1bd22f6b Mon Sep 17 00:00:00 2001 From: Sasha Weiss Date: Fri, 19 Dec 2025 17:30:15 -0800 Subject: [PATCH] Enable swiftformat for the NSE and SAE --- .swiftformat | 2 - SignalNSE/NSECallMessageHandler.swift | 38 ++++---- SignalNSE/NSEContext.swift | 4 +- SignalNSE/NSEEnvironment.swift | 2 +- SignalNSE/NSELogger.swift | 2 +- SignalNSE/NotificationService.swift | 12 +-- .../SAEFailedViewController.swift | 2 +- .../SAELoadViewController.swift | 12 ++- .../SAEScreenLockViewController.swift | 6 +- .../ShareAppExtensionContext.swift | 94 +++++++++++-------- .../ShareViewController.swift | 44 +++++---- .../SharingThreadPickerProgressSheet.swift | 12 +-- .../SharingThreadPickerViewController.swift | 46 ++++----- 13 files changed, 149 insertions(+), 127 deletions(-) diff --git a/.swiftformat b/.swiftformat index 622a069d93..fb0eea5435 100644 --- a/.swiftformat +++ b/.swiftformat @@ -6,9 +6,7 @@ # Temporary excludes. --exclude Signal ---exclude SignalNSE --exclude SignalServiceKit ---exclude SignalShareExtension --exclude SignalUI --swift-version 6.2 diff --git a/SignalNSE/NSECallMessageHandler.swift b/SignalNSE/NSECallMessageHandler.swift index 3797e41f8c..8b71c82084 100644 --- a/SignalNSE/NSECallMessageHandler.swift +++ b/SignalNSE/NSECallMessageHandler.swift @@ -37,7 +37,7 @@ class NSECallMessageHandler: CallMessageHandler { sentAtTimestamp: UInt64, serverReceivedTimestamp: UInt64, serverDeliveryTimestamp: UInt64, - tx: DBWriteTransaction + tx: DBWriteTransaction, ) { let bufferSecondsForMainAppToAnswerRing: UInt64 = 10 @@ -54,7 +54,7 @@ class NSECallMessageHandler: CallMessageHandler { identityManager: identityManager, notificationPresenter: notificationPresenter, profileManager: profileManager, - tsAccountManager: tsAccountManager + tsAccountManager: tsAccountManager, ) let partialResult = callOfferHandler.startHandlingOffer( caller: caller.aci, @@ -63,7 +63,7 @@ class NSECallMessageHandler: CallMessageHandler { callId: offer.id, callType: offer.type ?? .offerAudioCall, sentAtTimestamp: sentAtTimestamp, - tx: tx + tx: tx, ) guard let partialResult else { return @@ -77,7 +77,7 @@ class NSECallMessageHandler: CallMessageHandler { let isValid = isValidOfferMessage( opaque: opaque, messageAgeSec: messageAgeForRingRtc, - callMediaType: callType + callMediaType: callType, ) guard isValid else { NSELogger.uncorrelated.warn("missed a call because it's not valid (according to RingRTC)") @@ -87,7 +87,7 @@ class NSECallMessageHandler: CallMessageHandler { outcome: .incomingMissed, callType: partialResult.offerMediaType, sentAtTimestamp: sentAtTimestamp, - tx: tx + tx: tx, ) return } @@ -110,11 +110,13 @@ class NSECallMessageHandler: CallMessageHandler { return false } - guard GroupMessageProcessorManager.discardMode( - forMessageFrom: caller.aci, - groupId: groupId, - tx: transaction - ) == .doNotDiscard else { + guard + GroupMessageProcessorManager.discardMode( + forMessageFrom: caller.aci, + groupId: groupId, + tx: transaction, + ) == .doNotDiscard + else { NSELogger.uncorrelated.warn("discarding group ring \(ringId) from \(caller.aci)") return false } @@ -138,7 +140,7 @@ class NSECallMessageHandler: CallMessageHandler { return isValidOpaqueRing( opaqueCallMessage: opaqueData, messageAgeSec: messageAgeForRingRtc, - validateGroupRing: validateGroupRing + validateGroupRing: validateGroupRing, ) }() guard shouldHandleExternally else { @@ -156,7 +158,7 @@ class NSECallMessageHandler: CallMessageHandler { plaintextData: plaintextData, wasReceivedByUD: wasReceivedByUD, serverDeliveryTimestamp: serverDeliveryTimestamp, - tx: tx + tx: tx, ) } @@ -165,7 +167,7 @@ class NSECallMessageHandler: CallMessageHandler { plaintextData: Data, wasReceivedByUD: Bool, serverDeliveryTimestamp: UInt64, - tx: DBWriteTransaction + tx: DBWriteTransaction, ) { do { let payload = try CallMessageRelay.enqueueCallMessageForMainApp( @@ -173,7 +175,7 @@ class NSECallMessageHandler: CallMessageHandler { plaintextData: plaintextData, wasReceivedByUD: wasReceivedByUD, serverDeliveryTimestamp: serverDeliveryTimestamp, - transaction: tx + transaction: tx, ) // We don't want to risk consuming any call messages that the main app needs to perform the call @@ -185,7 +187,7 @@ class NSECallMessageHandler: CallMessageHandler { NSELogger.uncorrelated.info("Notifying primary app of incoming call with push payload: \(payload)") CXProvider.reportNewIncomingVoIPPushPayload(payload.payloadDict) { error in - if let error = error { + if let error { owsFailDebug("Failed to notify main app of call message: \(error)") } else { NSELogger.uncorrelated.info("Successfully notified main app of call message.") @@ -199,14 +201,14 @@ class NSECallMessageHandler: CallMessageHandler { func receivedGroupCallUpdateMessage( _ updateMessage: SSKProtoDataMessageGroupCallUpdate, forGroupId groupId: GroupIdentifier, - serverReceivedTimestamp: UInt64 + serverReceivedTimestamp: UInt64, ) async { await groupCallManager.peekGroupCallAndUpdateThread( forGroupId: groupId, peekTrigger: .receivedGroupUpdateMessage( eraId: updateMessage.eraID, - messageTimestamp: serverReceivedTimestamp - ) + messageTimestamp: serverReceivedTimestamp, + ), ) } } diff --git a/SignalNSE/NSEContext.swift b/SignalNSE/NSEContext.swift index 6c10a463f9..ef733a62ba 100644 --- a/SignalNSE/NSEContext.swift +++ b/SignalNSE/NSEContext.swift @@ -47,7 +47,7 @@ class NSEContext: NSObject, AppContext { let memoryPressureSource = DispatchSource.makeMemoryPressureSource( eventMask: .all, - queue: .global() + queue: .global(), ) override init() { @@ -88,7 +88,7 @@ class NSEContext: NSObject, AppContext { } } -fileprivate extension DispatchSourceMemoryPressure { +private extension DispatchSourceMemoryPressure { var memoryEvent: DispatchSource.MemoryPressureEvent { DispatchSource.MemoryPressureEvent(rawValue: data) } diff --git a/SignalNSE/NSEEnvironment.swift b/SignalNSE/NSEEnvironment.swift index bcb5d9f2cd..762278fed4 100644 --- a/SignalNSE/NSEEnvironment.swift +++ b/SignalNSE/NSEEnvironment.swift @@ -50,7 +50,7 @@ class NSEEnvironment { let databaseStorage = try SDSDatabaseStorage( appReadiness: appReadiness, databaseFileUrl: SDSDatabaseStorage.grdbDatabaseFileUrl, - keychainStorage: keychainStorage + keychainStorage: keychainStorage, ) databaseStorage.grdbStorage.setUpDatabasePathKVO() diff --git a/SignalNSE/NSELogger.swift b/SignalNSE/NSELogger.swift index 1b9febd055..faf56624a0 100644 --- a/SignalNSE/NSELogger.swift +++ b/SignalNSE/NSELogger.swift @@ -12,7 +12,7 @@ class NSELogger: PrefixedLogger { convenience init() { self.init( prefix: "[NSE]", - suffix: "{{\(UUID().uuidString)}}" + suffix: "{{\(UUID().uuidString)}}", ) } } diff --git a/SignalNSE/NotificationService.swift b/SignalNSE/NotificationService.swift index 0f7120b689..776d8819f3 100644 --- a/SignalNSE/NotificationService.swift +++ b/SignalNSE/NotificationService.swift @@ -3,8 +3,8 @@ // SPDX-License-Identifier: AGPL-3.0-only // -import UserNotifications import SignalServiceKit +import UserNotifications // The lifecycle of the NSE looks something like the following: // 1) App receives notification @@ -83,7 +83,7 @@ class NotificationService: UNNotificationServiceExtension { override func didReceive( _ request: UNNotificationRequest, - withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void + withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void, ) { let logger = NSELogger() _ = Self.nseDidStart() @@ -109,7 +109,7 @@ class NotificationService: UNNotificationServiceExtension { let content = UNMutableNotificationContent() let notificationFormat = OWSLocalizedString( "NOTIFICATION_BODY_PHONE_LOCKED_FORMAT", - comment: "Lock screen notification text presented after user powers on their device without unlocking. Embeds {{device model}} (either 'iPad' or 'iPhone')" + comment: "Lock screen notification text presented after user powers on their device without unlocking. Embeds {{device model}} (either 'iPad' or 'iPhone')", ) content.body = String(format: notificationFormat, UIDevice.current.localizedModel) return content @@ -130,7 +130,7 @@ class NotificationService: UNNotificationServiceExtension { // Re-set up the local identifiers to ensure they're propagated throughout the system. switch finalContinuation.setUpLocalIdentifiers( willResumeInProgressRegistration: false, - canInitiateRegistration: false + canInitiateRegistration: false, ) { case .corruptRegistrationState: Logger.warn("Ignoring request to process notifications when the user isn't registered.") @@ -170,8 +170,8 @@ class NotificationService: UNNotificationServiceExtension { try await Preconditions([ NotificationPrecondition( notificationName: .isSignalProxyReadyDidChange, - isSatisfied: { SignalProxy.isEnabledAndReady } - ) + isSatisfied: { SignalProxy.isEnabledAndReady }, + ), ]).waitUntilSatisfied() } } diff --git a/SignalShareExtension/SAEFailedViewController.swift b/SignalShareExtension/SAEFailedViewController.swift index face57767c..7d84d2f28a 100644 --- a/SignalShareExtension/SAEFailedViewController.swift +++ b/SignalShareExtension/SAEFailedViewController.swift @@ -85,7 +85,7 @@ class SAEFailedViewController: UIViewController { // MARK: - Event Handlers private func cancelPressed() { - guard let delegate = delegate else { + guard let delegate else { owsFailDebug("missing delegate") return } diff --git a/SignalShareExtension/SAELoadViewController.swift b/SignalShareExtension/SAELoadViewController.swift index 4d8c16743d..4a34627ee1 100644 --- a/SignalShareExtension/SAELoadViewController.swift +++ b/SignalShareExtension/SAELoadViewController.swift @@ -3,10 +3,10 @@ // SPDX-License-Identifier: AGPL-3.0-only // -import UIKit import PureLayout import SignalServiceKit import SignalUI +import UIKit class SAELoadViewController: UIViewController, OWSNavigationChildController { @@ -73,8 +73,8 @@ class SAELoadViewController: UIViewController, OWSNavigationChildController { self.view.backgroundColor = ( self.shouldMimicRecipientPicker - ? Theme.tableView2PresentedBackgroundColor - : Theme.backgroundColor + ? Theme.tableView2PresentedBackgroundColor + : Theme.backgroundColor, ) let activityIndicator = UIActivityIndicatorView(style: .large) @@ -96,8 +96,10 @@ class SAELoadViewController: UIViewController, OWSNavigationChildController { let label = UILabel() label.textColor = Theme.primaryTextColor label.font = .systemFont(ofSize: 17) - label.text = OWSLocalizedString("SHARE_EXTENSION_LOADING", - comment: "Indicates that the share extension is still loading.") + label.text = OWSLocalizedString( + "SHARE_EXTENSION_LOADING", + comment: "Indicates that the share extension is still loading.", + ) self.view.addSubview(label) label.autoHCenterInSuperview() label.autoPinEdge(.top, to: .bottom, of: activityIndicator, withOffset: 12) diff --git a/SignalShareExtension/SAEScreenLockViewController.swift b/SignalShareExtension/SAEScreenLockViewController.swift index 676ac5e63d..d2286947ad 100644 --- a/SignalShareExtension/SAEScreenLockViewController.swift +++ b/SignalShareExtension/SAEScreenLockViewController.swift @@ -110,7 +110,7 @@ final class SAEScreenLockViewController: ScreenLockViewController { self.isShowingAuthUI = false self.ensureUI() - } + }, ) ensureUI() @@ -122,13 +122,13 @@ final class SAEScreenLockViewController: ScreenLockViewController { OWSActionSheets.showActionSheet( title: OWSLocalizedString( "SCREEN_LOCK_UNLOCK_FAILED", - comment: "Title for alert indicating that screen lock could not be unlocked." + comment: "Title for alert indicating that screen lock could not be unlocked.", ), buttonAction: { _ in // After the alert, update the UI. self.ensureUI() }, - fromViewController: self + fromViewController: self, ) } diff --git a/SignalShareExtension/ShareAppExtensionContext.swift b/SignalShareExtension/ShareAppExtensionContext.swift index f82f832a69..63594ede2c 100644 --- a/SignalShareExtension/ShareAppExtensionContext.swift +++ b/SignalShareExtension/ShareAppExtensionContext.swift @@ -18,7 +18,7 @@ final class ShareAppExtensionContext: NSObject { private var notificationCenterObservers = [NSObjectProtocol]() - static private let isRTL: Bool = { + private static let isRTL: Bool = { // Borrowed from PureLayout's AppExtension compatible RTL support. // App Extensions may not access UIApplication.sharedApplication. // Fall back to checking the bundle's preferred localization character direction @@ -32,61 +32,73 @@ final class ShareAppExtensionContext: NSObject { super.init() let mainQueue = OperationQueue.main - notificationCenterObservers.append(NotificationCenter.default.addObserver( - forName: NSNotification.Name.NSExtensionHostDidBecomeActive, - object: nil, - queue: mainQueue) { [weak self] notification in + notificationCenterObservers.append( + NotificationCenter.default.addObserver( + forName: NSNotification.Name.NSExtensionHostDidBecomeActive, + object: nil, + queue: mainQueue, + ) { [weak self] notification in Logger.info("NSExtensionHostDidBecomeActive") self?.internalReportedApplicationState = .active BenchManager.bench( title: "Slow post DidBecomeActive", logIfLongerThan: 0.01, - logInProduction: true) { - NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationDidBecomeActive, object: nil) - } - } + logInProduction: true, + ) { + NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationDidBecomeActive, object: nil) + } + }, ) - notificationCenterObservers.append(NotificationCenter.default.addObserver( - forName: NSNotification.Name.NSExtensionHostWillResignActive, - object: nil, - queue: mainQueue) { [weak self] notification in + notificationCenterObservers.append( + NotificationCenter.default.addObserver( + forName: NSNotification.Name.NSExtensionHostWillResignActive, + object: nil, + queue: mainQueue, + ) { [weak self] notification in Logger.info("NSExtensionHostWillResignActive") self?.internalReportedApplicationState = .inactive BenchManager.bench( title: "Slow post WillResignActive", logIfLongerThan: 0.01, - logInProduction: true) { - NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationWillResignActive, object: nil) - } - } + logInProduction: true, + ) { + NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationWillResignActive, object: nil) + } + }, ) - notificationCenterObservers.append(NotificationCenter.default.addObserver( - forName: NSNotification.Name.NSExtensionHostDidEnterBackground, - object: nil, - queue: mainQueue) { [weak self] notification in + notificationCenterObservers.append( + NotificationCenter.default.addObserver( + forName: NSNotification.Name.NSExtensionHostDidEnterBackground, + object: nil, + queue: mainQueue, + ) { [weak self] notification in Logger.info("NSExtensionHostDidEnterBackground") self?.internalReportedApplicationState = .background BenchManager.bench( title: "Slow post DidEnterBackground", logIfLongerThan: 0.01, - logInProduction: true) { - NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationDidEnterBackground, object: nil) - } - } + logInProduction: true, + ) { + NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationDidEnterBackground, object: nil) + } + }, ) - notificationCenterObservers.append(NotificationCenter.default.addObserver( - forName: NSNotification.Name.NSExtensionHostWillEnterForeground, - object: nil, - queue: mainQueue) { [weak self] notification in + notificationCenterObservers.append( + NotificationCenter.default.addObserver( + forName: NSNotification.Name.NSExtensionHostWillEnterForeground, + object: nil, + queue: mainQueue, + ) { [weak self] notification in Logger.info("NSExtensionHostWillEnterForeground") self?.internalReportedApplicationState = .inactive BenchManager.bench( title: "Slow post WillEnterForeground", logIfLongerThan: 0.01, - logInProduction: true) { - NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationWillEnterForeground, object: nil) - } - } + logInProduction: true, + ) { + NotificationCenter.default.post(name: NSNotification.Name.OWSApplicationWillEnterForeground, object: nil) + } + }, ) } @@ -141,10 +153,11 @@ extension ShareAppExtensionContext: AppContext { } func appDocumentDirectoryPath() -> String { - guard let documentDirectoryURL = FileManager.default.urls( - for: .documentDirectory, - in: .userDomainMask - ).last + guard + let documentDirectoryURL = FileManager.default.urls( + for: .documentDirectory, + in: .userDomainMask, + ).last else { owsFail("Could not find documents directory.") } @@ -152,9 +165,10 @@ extension ShareAppExtensionContext: AppContext { } func appSharedDataDirectoryPath() -> String { - guard let groupContainerDirectoryURL = FileManager.default.containerURL( - forSecurityApplicationGroupIdentifier: TSConstants.applicationGroup - ) + guard + let groupContainerDirectoryURL = FileManager.default.containerURL( + forSecurityApplicationGroupIdentifier: TSConstants.applicationGroup, + ) else { owsFail("Could not find application group directory.") } diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index 53478e4af1..8b492ce8aa 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -53,7 +53,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA self.initialLoadViewController = initialLoadViewController } - public override func viewDidAppear(_ animated: Bool) { + override public func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if let initialLoadViewController = self.initialLoadViewController.take() { @@ -74,7 +74,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA databaseStorage = try SDSDatabaseStorage( appReadiness: appReadiness, databaseFileUrl: SDSDatabaseStorage.grdbDatabaseFileUrl, - keychainStorage: keychainStorage + keychainStorage: keychainStorage, ) } catch { self.showNotRegisteredView() @@ -103,14 +103,14 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA // Configure the rest of the globals before preparing the database. SUIEnvironment.shared.setUp( appReadiness: appReadiness, - authCredentialManager: databaseContinuation.authCredentialManager + authCredentialManager: databaseContinuation.authCredentialManager, ) let finalContinuation = await databaseContinuation.migrateDatabaseData() finalContinuation.runLaunchTasksIfNeededAndReloadCaches() switch finalContinuation.setUpLocalIdentifiers( willResumeInProgressRegistration: false, - canInitiateRegistration: false + canInitiateRegistration: false, ) { case .corruptRegistrationState: self.showNotRegisteredView() @@ -154,7 +154,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA let conversationPicker: SharingThreadPickerViewController conversationPicker = SharingThreadPickerViewController( areAttachmentStoriesCompatPrecheck: typedItemProviders.allSatisfy { $0.isStoriesCompatible }, - shareViewDelegate: self + shareViewDelegate: self, ) let preSelectedThread = self.fetchPreSelectedThread() @@ -202,7 +202,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA }() typedItems = try await buildAndValidateAttachments( for: typedItemProviders, - setProgress: { loadViewControllerForProgress?.progress = $0 } + setProgress: { loadViewControllerForProgress?.progress = $0 }, ) } catch { self.presentAttachmentError(error) @@ -227,7 +227,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA self, selector: #selector(applicationDidEnterBackground), name: .OWSApplicationDidEnterBackground, - object: nil + object: nil, ) Logger.info("completed.") @@ -272,10 +272,14 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA private func showNotRegisteredView() { AssertIsOnMainThread() - let failureTitle = OWSLocalizedString("SHARE_EXTENSION_NOT_REGISTERED_TITLE", - comment: "Title indicating that the share extension cannot be used until the user has registered in the main app.") - let failureMessage = OWSLocalizedString("SHARE_EXTENSION_NOT_REGISTERED_MESSAGE", - comment: "Message indicating that the share extension cannot be used until the user has registered in the main app.") + let failureTitle = OWSLocalizedString( + "SHARE_EXTENSION_NOT_REGISTERED_TITLE", + comment: "Title indicating that the share extension cannot be used until the user has registered in the main app.", + ) + let failureMessage = OWSLocalizedString( + "SHARE_EXTENSION_NOT_REGISTERED_MESSAGE", + comment: "Message indicating that the share extension cannot be used until the user has registered in the main app.", + ) showErrorView(title: failureTitle, message: failureMessage) } @@ -378,7 +382,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA private func buildAndValidateAttachments( for typedItemProviders: [TypedItemProvider], - setProgress: @MainActor (Progress) -> Void + setProgress: @MainActor (Progress) -> Void, ) async throws -> [TypedItem] { let progress = Progress(totalUnitCount: Int64(typedItemProviders.count)) @@ -406,27 +410,27 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA case ShareViewControllerError.tooManyAttachments: let format = OWSLocalizedString( "IMAGE_PICKER_CAN_SELECT_NO_MORE_TOAST_FORMAT", - comment: "Momentarily shown to the user when attempting to select more images than is allowed. Embeds {{max number of items}} that can be shared." + comment: "Momentarily shown to the user when attempting to select more images than is allowed. Embeds {{max number of items}} that can be shared.", ) let alertTitle = String(format: format, OWSFormat.formatInt(SignalAttachment.maxAttachmentsAllowed)) OWSActionSheets.showActionSheet( title: alertTitle, - buttonTitle: CommonStrings.cancelButton + buttonTitle: CommonStrings.cancelButton, ) { _ in self.shareViewWasCancelled() } default: let alertTitle = OWSLocalizedString( "SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE", - comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details." + comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details.", ) OWSActionSheets.showActionSheet( title: alertTitle, message: error.userErrorDescription, - buttonTitle: CommonStrings.cancelButton + buttonTitle: CommonStrings.cancelButton, ) { _ in self.shareViewWasCancelled() } @@ -445,9 +449,11 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA // Handle safari sharing images and PDFs as two separate items one with the object to share and the other as the URL of the data. for extensionItem in extensionItems { for attachment in extensionItem.attachments ?? [] { - if attachment.hasItemConformingToTypeIdentifier(UTType.data.identifier) + if + attachment.hasItemConformingToTypeIdentifier(UTType.data.identifier) || attachment.hasItemConformingToTypeIdentifier(UTType.fileURL.identifier) - || attachment.hasItemConformingToTypeIdentifier("com.apple.pkpass") { + || attachment.hasItemConformingToTypeIdentifier("com.apple.pkpass") + { return extensionItem } } @@ -464,7 +470,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA return result } - public override func viewDidDisappear(_ animated: Bool) { + override public func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) // If we're disappearing because we presented something else (e.g., image diff --git a/SignalShareExtension/SharingThreadPickerProgressSheet.swift b/SignalShareExtension/SharingThreadPickerProgressSheet.swift index b10bd1c8eb..108c35d4c4 100644 --- a/SignalShareExtension/SharingThreadPickerProgressSheet.swift +++ b/SignalShareExtension/SharingThreadPickerProgressSheet.swift @@ -15,7 +15,7 @@ public class SharingThreadPickerProgressSheet: ActionSheetController { public init( attachmentIds: [Attachment.IDType], - delegate: ShareViewDelegate? + delegate: ShareViewDelegate?, ) { self.attachmentIds = attachmentIds super.init() @@ -24,7 +24,7 @@ public class SharingThreadPickerProgressSheet: ActionSheetController { let cancelAction = ActionSheetAction( title: CommonStrings.cancelButton, - style: .cancel + style: .cancel, ) { [weak delegate] _ in delegate?.shareViewWasCancelled() } @@ -34,7 +34,7 @@ public class SharingThreadPickerProgressSheet: ActionSheetController { self, selector: #selector(handleAttachmentProgressNotification(_:)), name: Upload.Constants.attachmentUploadProgressNotification, - object: nil + object: nil, ) } @@ -90,7 +90,7 @@ public class SharingThreadPickerProgressSheet: ActionSheetController { guard attachmentIds.isEmpty.negated else { progressLabel.text = OWSLocalizedString( "MESSAGE_STATUS_SENDING", - comment: "message status while message is sending." + comment: "message status while message is sending.", ) return } @@ -109,13 +109,13 @@ public class SharingThreadPickerProgressSheet: ActionSheetController { progressLabel.text = String( format: Self.progressFormat, OWSFormat.formatInt(min(totalCompleted + 1, attachmentIds.count)), - OWSFormat.formatInt(attachmentIds.count) + OWSFormat.formatInt(attachmentIds.count), ) } private static let progressFormat = OWSLocalizedString( "SHARE_EXTENSION_SENDING_IN_PROGRESS_FORMAT", - comment: "Send progress for share extension. Embeds {{ %1$@ number of attachments uploaded, %2$@ total number of attachments}}" + comment: "Send progress for share extension. Embeds {{ %1$@ number of attachments uploaded, %2$@ total number of attachments}}", ) // MARK: Notifications diff --git a/SignalShareExtension/SharingThreadPickerViewController.swift b/SignalShareExtension/SharingThreadPickerViewController.swift index 8121ef2420..bb2457b3e5 100644 --- a/SignalShareExtension/SharingThreadPickerViewController.swift +++ b/SignalShareExtension/SharingThreadPickerViewController.swift @@ -24,7 +24,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { /// the attachments end up being incompatible, because it would be weird to /// have the stories destinations disappear. Instead, we show an error when /// actually sending if stories are selected. - public let areAttachmentStoriesCompatPrecheck: Bool + let areAttachmentStoriesCompatPrecheck: Bool var typedItems: [TypedItem] { didSet { @@ -38,7 +38,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { private var selectedConversations: [ConversationItem] { selection.conversations } - public init(areAttachmentStoriesCompatPrecheck: Bool, shareViewDelegate: ShareViewDelegate) { + init(areAttachmentStoriesCompatPrecheck: Bool, shareViewDelegate: ShareViewDelegate) { self.typedItems = [] self.areAttachmentStoriesCompatPrecheck = areAttachmentStoriesCompatPrecheck self.shareViewDelegate = shareViewDelegate @@ -52,7 +52,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { self.updateApprovalMode() } - public func presentActionSheetOnNavigationController(_ alert: ActionSheetController) { + func presentActionSheetOnNavigationController(_ alert: ActionSheetController) { if let navigationController = shareViewDelegate?.shareViewNavigationController { navigationController.presentActionSheet(alert) } else { @@ -65,8 +65,8 @@ class SharingThreadPickerViewController: ConversationPickerViewController { guard selectedConversations.count == 1, - case .group(let groupThreadId) = selectedConversations.first?.messageRecipient else - { + case .group(let groupThreadId) = selectedConversations.first?.messageRecipient + else { mentionCandidates = [] return } @@ -142,7 +142,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { profileManager: SSKEnvironment.shared.profileManagerRef, recipientManager: DependenciesBridge.shared.recipientManager, tsAccountManager: DependenciesBridge.shared.tsAccountManager, - tx: tx + tx: tx, ) } let approvalView = ContactShareViewController(contactShareDraft: contactShareDraft) @@ -161,7 +161,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { return AttachmentApprovalItem(attachment: attachment, canSave: false) } } - var approvalVCOptions: AttachmentApprovalViewControllerOptions = withCancelButton ? [ .hasCancel ] : [] + var approvalVCOptions: AttachmentApprovalViewControllerOptions = withCancelButton ? [.hasCancel] : [] if self.selection.conversations.contains(where: \.isStory) { approvalVCOptions.insert(.disallowViewOnce) } @@ -234,7 +234,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { messageBody: destination.messageBody, quotedReplyDraft: nil, linkPreviewDataSource: linkPreviewDataSource, - transaction: tx + transaction: tx, ) return try unpreparedMessage.prepare(tx: tx) }, @@ -244,9 +244,9 @@ class SharingThreadPickerViewController: ConversationPickerViewController { try await StorySharing.enqueueTextStory( with: messageBody, linkPreviewDraft: linkPreview, - to: conversations + to: conversations, ) - } + }, ) case .contact(let contactShare): let contactShareForSending: ContactShareDraft.ForSending @@ -265,14 +265,14 @@ class SharingThreadPickerViewController: ConversationPickerViewController { thread: destination.thread, expiresInSeconds: dmConfigurationStore.durationSeconds( for: destination.thread, - tx: tx - ) + tx: tx, + ), ) let message = builder.build(transaction: tx) let unpreparedMessage = UnpreparedOutgoingMessage.forMessage( message, body: nil, - contactShareDraft: contactShareForSending + contactShareDraft: contactShareForSending, ) return try unpreparedMessage.prepare(tx: tx) }, @@ -326,7 +326,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { } else { let actionSheet = SharingThreadPickerProgressSheet( attachmentIds: attachmentIds, - delegate: self.shareViewDelegate + delegate: self.shareViewDelegate, ) presentActionSheetOnNavigationController(actionSheet) self.sendProgressSheet = actionSheet @@ -370,14 +370,14 @@ class SharingThreadPickerViewController: ConversationPickerViewController { ThreadUtil.addThreadToProfileWhitelistIfEmptyOrPendingRequest( destination.thread, setDefaultTimerIfNecessary: true, - tx: tx + tx: tx, ) } let sendPromises = preparedMessages.map { ThreadUtil.enqueueMessagePromise( message: $0, - transaction: tx + transaction: tx, ) } return (preparedMessages, sendPromises) @@ -427,9 +427,9 @@ class SharingThreadPickerViewController: ConversationPickerViewController { let cancelAction = ActionSheetAction( title: CommonStrings.cancelButton, - style: .cancel + style: .cancel, ) { [weak self] _ in - guard let self = self else { return } + guard let self else { return } SSKEnvironment.shared.databaseStorageRef.write { transaction in for message in failure.outgoingMessages { // If we sent the message to anyone, mark it as failed @@ -445,7 +445,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { let untrustedServiceId = untrustedIdentityError.serviceId let failureFormat = OWSLocalizedString( "SHARE_EXTENSION_FAILED_SENDING_BECAUSE_UNTRUSTED_IDENTITY_FORMAT", - comment: "alert body when sharing file failed because of untrusted/changed identity keys" + comment: "alert body when sharing file failed because of untrusted/changed identity keys", ) let displayName = SSKEnvironment.shared.databaseStorageRef.read { tx in return SSKEnvironment.shared.contactManagerRef.displayName(for: SignalServiceAddress(untrustedServiceId), tx: tx).resolvedValue() @@ -463,16 +463,16 @@ class SharingThreadPickerViewController: ConversationPickerViewController { let confirmAction = ActionSheetAction( title: SafetyNumberStrings.confirmSendButton, - style: .default + style: .default, ) { [weak self] _ in - guard let self = self else { return } + guard let self else { return } // Confirm Identity SSKEnvironment.shared.databaseStorageRef.write { transaction in let identityManager = DependenciesBridge.shared.identityManager let verificationState = identityManager.verificationState( for: SignalServiceAddress(untrustedServiceId), - tx: transaction + tx: transaction, ) switch verificationState { case .verified: @@ -488,7 +488,7 @@ class SharingThreadPickerViewController: ConversationPickerViewController { of: identityKey, for: SignalServiceAddress(untrustedServiceId), isUserInitiatedChange: true, - tx: transaction + tx: transaction, ) } }