diff --git a/NotificationServiceExtension/NotificationService.swift b/NotificationServiceExtension/NotificationService.swift
index daefe5c080..dd181c8938 100644
--- a/NotificationServiceExtension/NotificationService.swift
+++ b/NotificationServiceExtension/NotificationService.swift
@@ -5,7 +5,6 @@
import UserNotifications
import SignalMessaging
import SignalServiceKit
-import PromiseKit
// The lifecycle of the NSE looks something like the following:
// 1) App receives notification
diff --git a/Podfile b/Podfile
index 418ebe4130..44438c7e97 100644
--- a/Podfile
+++ b/Podfile
@@ -11,7 +11,7 @@ source 'https://cdn.cocoapods.org/'
pod 'SwiftProtobuf', ">= 1.14.0"
-pod 'SignalCoreKit', git: 'https://github.com/signalapp/SignalCoreKit', testspecs: ["Tests"]
+pod 'SignalCoreKit', git: 'ssh://git@github.com/signalapp/SignalCoreKit-Private', testspecs: ["Tests"], branch: 'nt/promises'
# pod 'SignalCoreKit', path: '../SignalCoreKit', testspecs: ["Tests"]
pod 'SignalClient', git: 'https://github.com/signalapp/libsignal-client.git', testspecs: ["Tests"]
@@ -33,8 +33,6 @@ pod 'ZKGroup', git: 'https://github.com/signalapp/zkgroup', testspecs: ["Tests"]
pod 'SignalArgon2', git: 'https://github.com/signalapp/Argon2.git', submodules: true, testspecs: ["Tests"]
# pod 'SignalArgon2', path: '../Argon2', testspecs: ["Tests"]
-pod 'PromiseKit'
-
# pod 'GRDB.swift/SQLCipher', path: '../GRDB.swift'
pod 'GRDB.swift/SQLCipher'
diff --git a/Podfile.lock b/Podfile.lock
index fcd7bd392b..3a52516d5c 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -83,15 +83,6 @@ PODS:
- SwiftNIOHTTP1 (~> 2.18)
- SwiftProtobuf (~> 1.5)
- OpenSSL-Universal (1.1.1100)
- - PromiseKit (6.13.1):
- - PromiseKit/CorePromise (= 6.13.1)
- - PromiseKit/Foundation (= 6.13.1)
- - PromiseKit/UIKit (= 6.13.1)
- - PromiseKit/CorePromise (6.13.1)
- - PromiseKit/Foundation (6.13.1):
- - PromiseKit/CorePromise
- - PromiseKit/UIKit (6.13.1):
- - PromiseKit/CorePromise
- PureLayout (3.1.4)
- Reachability (3.2)
- SAMKeychain (1.5.3)
@@ -120,11 +111,9 @@ PODS:
- SignalCoreKit
- SwiftProtobuf
- SignalRingRTC (2.10.8):
- - PromiseKit
- SignalCoreKit
- SignalRingRTC/WebRTC (= 2.10.8)
- SignalRingRTC/WebRTC (2.10.8):
- - PromiseKit
- SignalCoreKit
- SignalServiceKit (0.9.0):
- AFNetworking/NSURLSession
@@ -136,7 +125,6 @@ PODS:
- libwebp
- Mantle
- OpenSSL-Universal
- - PromiseKit (~> 6.0)
- Reachability
- SAMKeychain
- SignalArgon2
@@ -156,7 +144,6 @@ PODS:
- libwebp
- Mantle
- OpenSSL-Universal
- - PromiseKit (~> 6.0)
- Reachability
- SAMKeychain
- SignalArgon2
@@ -236,15 +223,14 @@ DEPENDENCIES:
- Mantle (from `https://github.com/signalapp/Mantle`, branch `signal-master`)
- MobileCoin (from `https://github.com/mobilecoinofficial/MobileCoin-Swift.git`, tag `v1.1.0`)
- OpenSSL-Universal (from `https://github.com/signalapp/GRKOpenSSLFramework`)
- - PromiseKit
- PureLayout
- Reachability
- SignalArgon2 (from `https://github.com/signalapp/Argon2.git`)
- SignalArgon2/Tests (from `https://github.com/signalapp/Argon2.git`)
- SignalClient (from `https://github.com/signalapp/libsignal-client.git`)
- SignalClient/Tests (from `https://github.com/signalapp/libsignal-client.git`)
- - SignalCoreKit (from `https://github.com/signalapp/SignalCoreKit`)
- - SignalCoreKit/Tests (from `https://github.com/signalapp/SignalCoreKit`)
+ - "SignalCoreKit (from `ssh://git@github.com/signalapp/SignalCoreKit-Private`, branch `nt/promises`)"
+ - "SignalCoreKit/Tests (from `ssh://git@github.com/signalapp/SignalCoreKit-Private`, branch `nt/promises`)"
- "SignalMetadataKit (from `ssh://git@github.com/signalapp/SignalMetadataKit`, branch `feature/SignalClient-adoption`)"
- "SignalMetadataKit/Tests (from `ssh://git@github.com/signalapp/SignalMetadataKit`, branch `feature/SignalClient-adoption`)"
- SignalRingRTC (from `ThirdParty/SignalRingRTC.podspec`)
@@ -277,7 +263,6 @@ SPEC REPOS:
- libwebp
- Logging
- lottie-ios
- - PromiseKit
- PureLayout
- Reachability
- SAMKeychain
@@ -322,7 +307,8 @@ EXTERNAL SOURCES:
SignalClient:
:git: https://github.com/signalapp/libsignal-client.git
SignalCoreKit:
- :git: https://github.com/signalapp/SignalCoreKit
+ :branch: nt/promises
+ :git: "ssh://git@github.com/signalapp/SignalCoreKit-Private"
SignalMetadataKit:
:branch: feature/SignalClient-adoption
:git: "ssh://git@github.com/signalapp/SignalMetadataKit"
@@ -368,8 +354,8 @@ CHECKOUT OPTIONS:
:commit: ffd2fe1664cd23d1ae7dc5d3a7c6c33bc702b93e
:git: https://github.com/signalapp/libsignal-client.git
SignalCoreKit:
- :commit: bacb5ab174e8638458ab2032a7a472422efdf165
- :git: https://github.com/signalapp/SignalCoreKit
+ :commit: 6cf76bc71dd15c1c4e19391d4da9e06d639dd883
+ :git: "ssh://git@github.com/signalapp/SignalCoreKit-Private"
SignalMetadataKit:
:commit: 4c8ddf0b04afd179f00d7b024b1c611e3ddd2b7d
:git: "ssh://git@github.com/signalapp/SignalMetadataKit"
@@ -407,7 +393,6 @@ SPEC CHECKSUMS:
Mantle: 2fa750afa478cd625a94230fbf1c13462f29395b
MobileCoin: 59f940b9f71e6fdcfd206150ebda839a132b58be
OpenSSL-Universal: d8fb58afffcf2dafe4ad99e17efe236bcd216c2e
- PromiseKit: 28fda91c973cc377875d8c0ea4f973013c05b6db
PureLayout: f08c01b8dec00bb14a1fefa3de4c7d9c265df85e
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c
@@ -415,8 +400,8 @@ SPEC CHECKSUMS:
SignalClient: 2353bbeaaa062b98457690c26e1d5e3c2cb772a0
SignalCoreKit: 87da14c58d57760793b892ff03838c5ef2ce1167
SignalMetadataKit: eb928ec98376ab5a6ef2108a7fcd3b2d792b8c65
- SignalRingRTC: 0b51c21e0424b156b45a28910c677b29b7840691
- SignalServiceKit: 5e25915a8275f4deff7f830a343c0fcb085d062b
+ SignalRingRTC: 665575d98c82e766f9248e3bd66cb775e7e4b9e7
+ SignalServiceKit: aaaad497e0597ea5049acfe04ac78cbc6e271583
SQLCipher: d305a7bd9af4b64f095c79bdc1a1fa50f2a15116
SSZipArchive: 41455d4b8d2b6ab93990820b50dc697c2554a322
Starscream: 8aaf1a7feb805c816d0e7d3190ef23856f6665b9
@@ -434,6 +419,6 @@ SPEC CHECKSUMS:
YYImage: f1ddd15ac032a58b78bbed1e012b50302d318331
ZKGroup: 81ba58bf87b5614b03d49364db221390bf257dd7
-PODFILE CHECKSUM: 4de3037acfe442a115b15e5f87d45cc73865bc86
+PODFILE CHECKSUM: 76ac182b70983a83ffd9c40a554d9653e61e1bd0
COCOAPODS: 1.10.1
diff --git a/Pods b/Pods
index f1206bdd95..2f17b95a04 160000
--- a/Pods
+++ b/Pods
@@ -1 +1 @@
-Subproject commit f1206bdd95b378c817b9cbbccd61b612d41fb0a3
+Subproject commit 2f17b95a0409ba838a066ac9912f5110f351c1b5
diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj
index c0579f3332..1f19c7d286 100644
--- a/Signal.xcodeproj/project.pbxproj
+++ b/Signal.xcodeproj/project.pbxproj
@@ -4878,7 +4878,6 @@
"${BUILT_PRODUCTS_DIR}/Logging/Logging.framework",
"${BUILT_PRODUCTS_DIR}/Mantle/Mantle.framework",
"${BUILT_PRODUCTS_DIR}/MobileCoin/MobileCoin.framework",
- "${BUILT_PRODUCTS_DIR}/PromiseKit/PromiseKit.framework",
"${BUILT_PRODUCTS_DIR}/PureLayout/PureLayout.framework",
"${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework",
"${BUILT_PRODUCTS_DIR}/SAMKeychain/SAMKeychain.framework",
@@ -4931,7 +4930,6 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Logging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mantle.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MobileCoin.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PromiseKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PureLayout.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SAMKeychain.framework",
@@ -5012,7 +5010,6 @@
"${BUILT_PRODUCTS_DIR}/Logging/Logging.framework",
"${BUILT_PRODUCTS_DIR}/Mantle/Mantle.framework",
"${BUILT_PRODUCTS_DIR}/MobileCoin/MobileCoin.framework",
- "${BUILT_PRODUCTS_DIR}/PromiseKit/PromiseKit.framework",
"${BUILT_PRODUCTS_DIR}/PureLayout/PureLayout.framework",
"${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework",
"${BUILT_PRODUCTS_DIR}/SAMKeychain/SAMKeychain.framework",
@@ -5062,7 +5059,6 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Logging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mantle.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MobileCoin.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PromiseKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PureLayout.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SAMKeychain.framework",
@@ -5162,7 +5158,6 @@
"${BUILT_PRODUCTS_DIR}/Logging/Logging.framework",
"${BUILT_PRODUCTS_DIR}/Mantle/Mantle.framework",
"${BUILT_PRODUCTS_DIR}/MobileCoin/MobileCoin.framework",
- "${BUILT_PRODUCTS_DIR}/PromiseKit/PromiseKit.framework",
"${BUILT_PRODUCTS_DIR}/PureLayout/PureLayout.framework",
"${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework",
"${BUILT_PRODUCTS_DIR}/SAMKeychain/SAMKeychain.framework",
@@ -5212,7 +5207,6 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Logging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mantle.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MobileCoin.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PromiseKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PureLayout.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SAMKeychain.framework",
diff --git a/Signal/Settings.bundle/Acknowledgements.plist b/Signal/Settings.bundle/Acknowledgements.plist
index 3b0d0bdc79..967368960e 100644
--- a/Signal/Settings.bundle/Acknowledgements.plist
+++ b/Signal/Settings.bundle/Acknowledgements.plist
@@ -1515,23 +1515,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Type
PSGroupSpecifier
-
- FooterText
- Copyright 2016-present, Max Howell; mxcl@me.com
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- License
- MIT
- Title
- PromiseKit
- Type
- PSGroupSpecifier
-
FooterText
This code is distributed under the terms and conditions of the MIT license.
diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m
index 989b56cf4b..876a8747e1 100644
--- a/Signal/src/AppDelegate.m
+++ b/Signal/src/AppDelegate.m
@@ -14,7 +14,7 @@
#import "SignalApp.h"
#import "ViewControllerUtils.h"
#import
-#import
+#import
#import
#import
#import
@@ -1110,7 +1110,7 @@ void uncaughtExceptionHandler(NSException *exception)
{
OWSLogInfo(@"performing background fetch");
AppReadinessRunNowOrWhenAppDidBecomeReadySync(^{
- [self.messageFetcherJob runObjc].then(^{
+ [self.messageFetcherJob runObjc].done(^(id value) {
// HACK: Call completion handler after n seconds.
//
// We don't currently have a convenient API to know when message fetching is *done* when
diff --git a/Signal/src/Calls/CallService.swift b/Signal/src/Calls/CallService.swift
index 3f49a87d73..a7e5695171 100644
--- a/Signal/src/Calls/CallService.swift
+++ b/Signal/src/Calls/CallService.swift
@@ -4,7 +4,6 @@
import Foundation
import SignalRingRTC
-import PromiseKit
// All Observer methods will be invoked from the main thread.
@objc(OWSCallServiceObserver)
@@ -745,7 +744,7 @@ extension CallService {
firstly {
self.fetchGroupMembershipProof(for: thread)
- }.then(on: .main) { (proof: Data) -> Promise in
+ }.then(on: .main) { (proof: Data) -> Guarantee in
let sfuURL = DebugFlags.callingUseTestSFU.get() ? TSConstants.sfuTestURL : TSConstants.sfuURL
return self.callManager.peekGroupCall(sfuUrl: sfuURL, membershipProof: proof, groupMembers: memberInfo)
}.done(on: .main) { info in
@@ -919,9 +918,9 @@ extension CallService: CallManagerDelegate {
transaction: transaction
)
}
- }.done { _ in
+ }.done(on: .main) { _ in
// TODO: Tell RingRTC we succeeded in sending the message. API TBD
- }.catch { error in
+ }.catch(on: .main) { error in
if error.isNetworkFailureOrTimeout {
Logger.warn("Failed to send opaque message \(error)")
} else if error is UntrustedIdentityError {
diff --git a/Signal/src/Calls/Individual/IndividualCallService.swift b/Signal/src/Calls/Individual/IndividualCallService.swift
index 4815b192f8..dc44088ac4 100644
--- a/Signal/src/Calls/Individual/IndividualCallService.swift
+++ b/Signal/src/Calls/Individual/IndividualCallService.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalRingRTC
import WebRTC
import SignalServiceKit
@@ -498,7 +497,7 @@ import SignalMessaging
Logger.info("call: \(call)")
// Start the call, asynchronously.
- getIceServers().done { iceServers in
+ getIceServers().done(on: .main) { iceServers in
guard self.callService.currentCall === call else {
Logger.debug("call has since ended")
return
@@ -864,10 +863,10 @@ import SignalMessaging
transaction: transaction
)
}
- }.done {
+ }.done(on: .main) {
Logger.info("sent offer message to \(call.individualCall.thread.contactAddress) device: \((destinationDeviceId != nil) ? String(destinationDeviceId!) : "nil")")
try self.callManager.signalingMessageDidSend(callId: callId)
- }.catch { error in
+ }.catch(on: .main) { error in
Logger.error("failed to send offer message to \(call.individualCall.thread.contactAddress) with error: \(error)")
self.callManager.signalingMessageDidFail(callId: callId)
}
@@ -891,10 +890,10 @@ import SignalMessaging
transaction: transaction
)
}
- }.done {
+ }.done(on: .main) {
Logger.debug("sent answer message to \(call.individualCall.thread.contactAddress) device: \((destinationDeviceId != nil) ? String(destinationDeviceId!) : "nil")")
try self.callManager.signalingMessageDidSend(callId: callId)
- }.catch { error in
+ }.catch(on: .main) { error in
Logger.error("failed to send answer message to \(call.individualCall.thread.contactAddress) with error: \(error)")
self.callManager.signalingMessageDidFail(callId: callId)
}
@@ -931,10 +930,10 @@ import SignalMessaging
transaction: transaction
)
}
- }.done {
+ }.done(on: .main) {
Logger.debug("sent ice update message to \(call.individualCall.thread.contactAddress) device: \((destinationDeviceId != nil) ? String(destinationDeviceId!) : "nil")")
try self.callManager.signalingMessageDidSend(callId: callId)
- }.catch { error in
+ }.catch(on: .main) { error in
Logger.error("failed to send ice update message to \(call.individualCall.thread.contactAddress) with error: \(error)")
callManager.signalingMessageDidFail(callId: callId)
}
@@ -977,10 +976,10 @@ import SignalMessaging
transaction: transaction
)
}
- }.done {
+ }.done(on: .main) {
Logger.debug("sent hangup message to \(call.individualCall.thread.contactAddress) device: \((destinationDeviceId != nil) ? String(destinationDeviceId!) : "nil")")
try self.callManager.signalingMessageDidSend(callId: callId)
- }.catch { error in
+ }.catch(on: .main) { error in
Logger.error("failed to send hangup message to \(call.individualCall.thread.contactAddress) with error: \(error)")
self.callManager.signalingMessageDidFail(callId: callId)
}
@@ -1003,10 +1002,10 @@ import SignalMessaging
transaction: transaction
)
}
- }.done {
+ }.done(on: .main) {
Logger.debug("sent busy message to \(call.individualCall.thread.contactAddress) device: \((destinationDeviceId != nil) ? String(destinationDeviceId!) : "nil")")
try self.callManager.signalingMessageDidSend(callId: callId)
- }.catch { error in
+ }.catch(on: .main) { error in
Logger.error("failed to send busy message to \(call.individualCall.thread.contactAddress) with error: \(error)")
self.callManager.signalingMessageDidFail(callId: callId)
}
diff --git a/Signal/src/Calls/UserInterface/Individual/CallUIAdapter.swift b/Signal/src/Calls/UserInterface/Individual/CallUIAdapter.swift
index 355e7fc874..bfbd5e611c 100644
--- a/Signal/src/Calls/UserInterface/Individual/CallUIAdapter.swift
+++ b/Signal/src/Calls/UserInterface/Individual/CallUIAdapter.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import CallKit
import SignalServiceKit
import SignalMessaging
diff --git a/Signal/src/Calls/UserInterface/Individual/IndividualCallViewController.swift b/Signal/src/Calls/UserInterface/Individual/IndividualCallViewController.swift
index ce3d9101b5..64395480fa 100644
--- a/Signal/src/Calls/UserInterface/Individual/IndividualCallViewController.swift
+++ b/Signal/src/Calls/UserInterface/Individual/IndividualCallViewController.swift
@@ -4,7 +4,6 @@
import Foundation
import WebRTC
-import PromiseKit
import SignalServiceKit
import SignalMessaging
import SignalRingRTC
diff --git a/Signal/src/Jobs/ConversationConfigurationSyncOperation.swift b/Signal/src/Jobs/ConversationConfigurationSyncOperation.swift
index 40368f9dd1..0b4b36fd9d 100644
--- a/Signal/src/Jobs/ConversationConfigurationSyncOperation.swift
+++ b/Signal/src/Jobs/ConversationConfigurationSyncOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
class ConversationConfigurationSyncOperation: OWSOperation {
diff --git a/Signal/src/Jobs/SessionResetJob.swift b/Signal/src/Jobs/SessionResetJob.swift
index 8fb2ea81de..71df0068bf 100644
--- a/Signal/src/Jobs/SessionResetJob.swift
+++ b/Signal/src/Jobs/SessionResetJob.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
@objc(OWSSessionResetJobQueue)
diff --git a/Signal/src/Jobs/SyncPushTokensJob.swift b/Signal/src/Jobs/SyncPushTokensJob.swift
index d4f9c369bf..07f31084f3 100644
--- a/Signal/src/Jobs/SyncPushTokensJob.swift
+++ b/Signal/src/Jobs/SyncPushTokensJob.swift
@@ -2,7 +2,6 @@
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
-import PromiseKit
import SignalServiceKit
@objc(OWSSyncPushTokensJob)
diff --git a/Signal/src/Models/AccountManager.swift b/Signal/src/Models/AccountManager.swift
index a72fefa23d..7d69007a35 100644
--- a/Signal/src/Models/AccountManager.swift
+++ b/Signal/src/Models/AccountManager.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
public enum AccountManagerError: Error {
@@ -62,8 +61,8 @@ public class AccountManager: NSObject {
return firstly {
return self.pushRegistrationManager.requestPushTokens()
}.then { (vanillaToken: String, voipToken: String?) -> Promise in
- let (pushPromise, pushResolver) = Promise.pending()
- self.pushRegistrationManager.preauthChallengeResolver = pushResolver
+ let (pushPromise, pushFuture) = Promise.pending()
+ self.pushRegistrationManager.preauthChallengeFuture = pushFuture
return self.accountServiceClient.requestPreauthChallenge(
recipientId: recipientId,
@@ -322,7 +321,7 @@ public class AccountManager: NSObject {
BenchEventComplete(eventId: "initial-contact-sync")
}
- return when(fulfilled: [storageServiceRestorePromise, initialSyncMessagePromise])
+ return Promise.when(fulfilled: [storageServiceRestorePromise, initialSyncMessagePromise])
}
}
@@ -334,7 +333,7 @@ public class AccountManager: NSObject {
private func registerForTextSecure(verificationCode: String, pin: String?, checkForAvailableTransfer: Bool) -> Promise {
let serverAuthToken = generateServerAuthToken()
- return Promise { resolver in
+ return Promise { future in
guard let phoneNumber = tsAccountManager.phoneNumberAwaitingVerification else {
throw OWSAssertionError("phoneNumberAwaitingVerification was unexpectedly nil")
}
@@ -346,8 +345,8 @@ public class AccountManager: NSObject {
checkForAvailableTransfer: checkForAvailableTransfer)
tsAccountManager.verifyAccount(request: request,
- success: resolver.fulfill,
- failure: resolver.reject)
+ success: future.resolve,
+ failure: future.reject)
}.map(on: .global()) { responseObject throws -> RegistrationResponse in
self.databaseStorage.write { transaction in
self.tsAccountManager.setStoredServerAuthToken(serverAuthToken,
@@ -407,9 +406,9 @@ public class AccountManager: NSObject {
}
private func createPreKeys() -> Promise {
- return Promise { resolver in
- TSPreKeyManager.createPreKeys(success: { resolver.fulfill(()) },
- failure: resolver.reject)
+ return Promise { future in
+ TSPreKeyManager.createPreKeys(success: { future.resolve() },
+ failure: future.reject)
}
}
@@ -428,11 +427,11 @@ public class AccountManager: NSObject {
// MARK: Message Delivery
func updatePushTokens(pushToken: String, voipToken: String?) -> Promise {
- return Promise { resolver in
+ return Promise { future in
tsAccountManager.registerForPushNotifications(pushToken: pushToken,
voipToken: voipToken,
- success: { resolver.fulfill(()) },
- failure: resolver.reject)
+ success: { future.resolve() },
+ failure: future.reject)
}
}
diff --git a/Signal/src/ViewControllers/AppSettings/ComposeSupportEmailOperation.swift b/Signal/src/ViewControllers/AppSettings/ComposeSupportEmailOperation.swift
index 59cda46720..77ac1f5574 100644
--- a/Signal/src/ViewControllers/AppSettings/ComposeSupportEmailOperation.swift
+++ b/Signal/src/ViewControllers/AppSettings/ComposeSupportEmailOperation.swift
@@ -4,7 +4,6 @@
import SignalServiceKit
import MessageUI
-import PromiseKit
struct SupportEmailModel: Dependencies {
@@ -168,12 +167,12 @@ final class ComposeSupportEmailOperation: NSObject {
}
private func open(mailURL url: URL) -> Promise {
- Promise { (resolver) in
+ Promise { future in
UIApplication.shared.open(url, options: [:]) { (success) in
if success {
- resolver.fulfill_()
+ future.resolve()
} else {
- resolver.reject(EmailError.failedToOpenURL)
+ future.reject(EmailError.failedToOpenURL)
}
}
}
diff --git a/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift b/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift
index d8fdbffae0..58f15e6c36 100644
--- a/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift
+++ b/Signal/src/ViewControllers/AppSettings/ContactSupportViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SafariServices
@objc(OWSSupportConstants)
@@ -248,10 +247,9 @@ final class ContactSupportViewController: OWSTableViewController2 {
comment: "Message for alert dialog presented when a support email failed to send")
OWSActionSheets.showActionSheet(title: alertTitle, message: alertMessage)
- }.finally(on: .main) {
+ }.ensure(on: .main) {
self.currentEmailComposeOperation = nil
self.showSpinnerOnNextButton = false
-
}
}
}
diff --git a/Signal/src/ViewControllers/AppSettings/DonationViewController.swift b/Signal/src/ViewControllers/AppSettings/DonationViewController.swift
index ab6b513fd5..a0d05c7e12 100644
--- a/Signal/src/ViewControllers/AppSettings/DonationViewController.swift
+++ b/Signal/src/ViewControllers/AppSettings/DonationViewController.swift
@@ -4,7 +4,6 @@
import Foundation
import PassKit
-import PromiseKit
import BonMot
/* From BonMot 6.0.0: If you're targeting iOS 15 or higher, you may want to check out [AttributedString](https://developer.apple.com/documentation/foundation/attributedstring) instead.
diff --git a/Signal/src/ViewControllers/AppSettings/Linked Devices/ScanQRCodeViewController.swift b/Signal/src/ViewControllers/AppSettings/Linked Devices/ScanQRCodeViewController.swift
index 15ee22c3d0..4a8dafd92e 100644
--- a/Signal/src/ViewControllers/AppSettings/Linked Devices/ScanQRCodeViewController.swift
+++ b/Signal/src/ViewControllers/AppSettings/Linked Devices/ScanQRCodeViewController.swift
@@ -4,7 +4,6 @@
import Foundation
import AVFoundation
-import PromiseKit
import Vision
@objc
diff --git a/Signal/src/ViewControllers/AppSettings/Payments/PaymentsSendRecipientViewController.swift b/Signal/src/ViewControllers/AppSettings/Payments/PaymentsSendRecipientViewController.swift
index add535ee09..d25db3e061 100644
--- a/Signal/src/ViewControllers/AppSettings/Payments/PaymentsSendRecipientViewController.swift
+++ b/Signal/src/ViewControllers/AppSettings/Payments/PaymentsSendRecipientViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
class PaymentsSendRecipientViewController: OWSViewController {
diff --git a/Signal/src/ViewControllers/AppSettings/Profile/ProfileSettingsViewController.swift b/Signal/src/ViewControllers/AppSettings/Profile/ProfileSettingsViewController.swift
index fb2321f94d..43db93e6a9 100644
--- a/Signal/src/ViewControllers/AppSettings/Profile/ProfileSettingsViewController.swift
+++ b/Signal/src/ViewControllers/AppSettings/Profile/ProfileSettingsViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
class ProfileSettingsViewController: OWSTableViewController2 {
@@ -193,12 +192,12 @@ class ProfileSettingsViewController: OWSTableViewController2 {
profileBioEmoji: normalizedBioEmoji,
profileAvatarData: avatarData,
userProfileWriter: .localUser)
- }.done { _ in
+ }.done(on: .main) { _ in
modalActivityIndicator.dismiss { [weak self] in
AssertIsOnMainThread()
self?.profileCompleted()
}
- }.catch { error in
+ }.catch(on: .main) { error in
owsFailDebug("Error: \(error)")
modalActivityIndicator.dismiss { [weak self] in
AssertIsOnMainThread()
diff --git a/Signal/src/ViewControllers/Attachment Keyboard/AttachmentFormatPickerView.swift b/Signal/src/ViewControllers/Attachment Keyboard/AttachmentFormatPickerView.swift
index bad5d5db8d..b8aed3f065 100644
--- a/Signal/src/ViewControllers/Attachment Keyboard/AttachmentFormatPickerView.swift
+++ b/Signal/src/ViewControllers/Attachment Keyboard/AttachmentFormatPickerView.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol AttachmentFormatPickerDelegate: AnyObject {
func didTapCamera()
diff --git a/Signal/src/ViewControllers/Attachment Keyboard/AttachmentKeyboard.swift b/Signal/src/ViewControllers/Attachment Keyboard/AttachmentKeyboard.swift
index 918639caff..965d8a73ac 100644
--- a/Signal/src/ViewControllers/Attachment Keyboard/AttachmentKeyboard.swift
+++ b/Signal/src/ViewControllers/Attachment Keyboard/AttachmentKeyboard.swift
@@ -4,7 +4,6 @@
import Foundation
import Photos
-import PromiseKit
@objc
protocol AttachmentKeyboardDelegate {
diff --git a/Signal/src/ViewControllers/Attachment Keyboard/RecentPhotoCollectionView.swift b/Signal/src/ViewControllers/Attachment Keyboard/RecentPhotoCollectionView.swift
index a1f93857eb..d2bc52c20d 100644
--- a/Signal/src/ViewControllers/Attachment Keyboard/RecentPhotoCollectionView.swift
+++ b/Signal/src/ViewControllers/Attachment Keyboard/RecentPhotoCollectionView.swift
@@ -5,7 +5,6 @@
import Foundation
import Photos
import PhotosUI
-import PromiseKit
protocol RecentPhotosDelegate: AnyObject {
var isMediaLibraryAccessGranted: Bool { get }
diff --git a/Signal/src/ViewControllers/CameraFirstNavigationController.swift b/Signal/src/ViewControllers/CameraFirstNavigationController.swift
index f8ef2b14b8..3d8fb1f028 100644
--- a/Signal/src/ViewControllers/CameraFirstNavigationController.swift
+++ b/Signal/src/ViewControllers/CameraFirstNavigationController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public protocol CameraFirstCaptureDelegate: AnyObject {
diff --git a/Signal/src/ViewControllers/ConversationView/BlockingAnnouncementOnlyView.swift b/Signal/src/ViewControllers/ConversationView/BlockingAnnouncementOnlyView.swift
index f827ef417b..5b74d6e07c 100644
--- a/Signal/src/ViewControllers/ConversationView/BlockingAnnouncementOnlyView.swift
+++ b/Signal/src/ViewControllers/ConversationView/BlockingAnnouncementOnlyView.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
class BlockingAnnouncementOnlyView: UIStackView {
diff --git a/Signal/src/ViewControllers/ConversationView/BlockingGroupMigrationView.swift b/Signal/src/ViewControllers/ConversationView/BlockingGroupMigrationView.swift
index ae5baf9a84..edc086126f 100644
--- a/Signal/src/ViewControllers/ConversationView/BlockingGroupMigrationView.swift
+++ b/Signal/src/ViewControllers/ConversationView/BlockingGroupMigrationView.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
class BlockingGroupMigrationView: UIStackView {
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVAvatarBuilder.swift b/Signal/src/ViewControllers/ConversationView/CV/CVAvatarBuilder.swift
index 66999275cd..cd6c49bd37 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVAvatarBuilder.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVAvatarBuilder.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// Caching builder used for a single CVC load.
// CVC loads often build the same avatars over and over.
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVComponentState+GroupLink.swift b/Signal/src/ViewControllers/ConversationView/CV/CVComponentState+GroupLink.swift
index 5e1c09d89d..d5ae4ff135 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVComponentState+GroupLink.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVComponentState+GroupLink.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
fileprivate extension CVComponentState {
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVComponentState.swift b/Signal/src/ViewControllers/ConversationView/CV/CVComponentState.swift
index f661f62d39..3c5b65f461 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVComponentState.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVComponentState.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
public class CVComponentState: Equatable, Dependencies {
let messageCellType: CVMessageCellType
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVItemViewState.swift b/Signal/src/ViewControllers/ConversationView/CV/CVItemViewState.swift
index 25d73621ef..2a66a5ba65 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVItemViewState.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVItemViewState.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// CVItemViewState represents the transient, un-persisted values
// that may affect item appearance.
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVLoadCoordinator.swift b/Signal/src/ViewControllers/ConversationView/CV/CVLoadCoordinator.swift
index 4b5b8fca18..dd325d41f6 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVLoadCoordinator.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVLoadCoordinator.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
protocol CVLoadCoordinatorDelegate: UIScrollViewDelegate {
@@ -79,7 +78,7 @@ public class CVLoadCoordinator: NSObject {
// TODO: Remove. This model will get stale.
private let thread: TSThread
- private var loadDidLandResolver: Resolver?
+ private var loadDidLandFuture: Future?
required init(viewState: CVViewState) {
self.viewState = viewState
@@ -605,7 +604,7 @@ public class CVLoadCoordinator: NSObject {
private func loadLandWhenSafePromise(update: CVUpdate) -> Promise {
AssertIsOnMainThread()
- let (loadPromise, loadResolver) = Promise.pending()
+ let (loadPromise, loadFuture) = Promise.pending()
loadLandWhenSafe(update: update, loadResolver: loadResolver)
@@ -734,12 +733,12 @@ public class CVLoadCoordinator: NSObject {
public func loadDidLand() {
AssertIsOnMainThread()
- guard let loadDidLandResolver = loadDidLandResolver else {
- owsFailDebug("Missing loadDidLandResolver.")
+ guard let loadDidLandFuture = loadDidLandFuture else {
+ owsFailDebug("Missing loadDidLandFuture.")
return
}
- loadDidLandResolver.fulfill(())
- self.loadDidLandResolver = nil
+ loadDidLandFuture.resolve()
+ self.loadDidLandFuture = nil
}
}
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVLoader.swift b/Signal/src/ViewControllers/ConversationView/CV/CVLoader.swift
index a68ea438cb..98b88621aa 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVLoader.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVLoader.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// This entity performs a single load.
public class CVLoader: NSObject {
diff --git a/Signal/src/ViewControllers/ConversationView/CV/CVViewStateSnapshot.swift b/Signal/src/ViewControllers/ConversationView/CV/CVViewStateSnapshot.swift
index ae7b85e858..e272ac7096 100644
--- a/Signal/src/ViewControllers/ConversationView/CV/CVViewStateSnapshot.swift
+++ b/Signal/src/ViewControllers/ConversationView/CV/CVViewStateSnapshot.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// This captures the CV view state that can affect the load.
// It is used when building, measuring & configuring components and their views.
diff --git a/Signal/src/ViewControllers/ConversationView/CVViewState.swift b/Signal/src/ViewControllers/ConversationView/CVViewState.swift
index bf860f476b..ad27e3cca3 100644
--- a/Signal/src/ViewControllers/ConversationView/CVViewState.swift
+++ b/Signal/src/ViewControllers/ConversationView/CVViewState.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
public protocol CVViewStateDelegate: AnyObject {
func viewStateUIModeDidChange(oldValue: ConversationUIMode)
diff --git a/Signal/src/ViewControllers/ConversationView/Cells/CVMediaView.swift b/Signal/src/ViewControllers/ConversationView/Cells/CVMediaView.swift
index 0bbac3848f..e932777bf1 100644
--- a/Signal/src/ViewControllers/ConversationView/Cells/CVMediaView.swift
+++ b/Signal/src/ViewControllers/ConversationView/Cells/CVMediaView.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
public class CVMediaView: ManualLayoutViewWithLayer {
diff --git a/Signal/src/ViewControllers/ConversationView/Cells/ReusableMediaView.swift b/Signal/src/ViewControllers/ConversationView/Cells/ReusableMediaView.swift
index d1c65780aa..92b4eb2156 100644
--- a/Signal/src/ViewControllers/ConversationView/Cells/ReusableMediaView.swift
+++ b/Signal/src/ViewControllers/ConversationView/Cells/ReusableMediaView.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// MARK: -
@@ -381,13 +380,13 @@ class MediaViewAdapterStill: MediaViewAdapterSwift {
guard attachmentStream.isValidImage else {
return Promise(error: ReusableMediaError.invalidMedia)
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
attachmentStream.thumbnailImage(quality: thumbnailQuality,
success: { (image) in
- resolver.fulfill(image)
+ future.resolve(image)
},
failure: {
- resolver.reject(OWSAssertionError("Could not load thumbnail"))
+ future.reject(OWSAssertionError("Could not load thumbnail"))
})
return promise
}
@@ -440,13 +439,13 @@ class MediaViewAdapterVideo: MediaViewAdapterSwift {
guard attachmentStream.isValidVideo else {
return Promise(error: ReusableMediaError.invalidMedia)
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
attachmentStream.thumbnailImage(quality: thumbnailQuality,
success: { (image) in
- resolver.fulfill(image)
+ future.resolve(image)
},
failure: {
- resolver.reject(OWSAssertionError("Could not load thumbnail"))
+ future.reject(OWSAssertionError("Could not load thumbnail"))
})
return promise
}
diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m
index 41bc3dfd77..db03e49478 100644
--- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m
+++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m
@@ -9,7 +9,7 @@
#import "Signal-Swift.h"
#import "UIFont+OWS.h"
#import "ViewControllerUtils.h"
-#import
+#import
#import
#import
#import
@@ -1434,7 +1434,7 @@ const CGFloat kMaxIPadTextViewHeight = 142;
__weak ConversationInputToolbar *weakSelf = self;
[self.linkPreviewManager fetchLinkPreviewForUrl:previewUrl]
- .then(^(OWSLinkPreviewDraft *linkPreviewDraft) {
+ .done(^(OWSLinkPreviewDraft *linkPreviewDraft) {
ConversationInputToolbar *_Nullable strongSelf = weakSelf;
if (!strongSelf) {
return;
diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVComponentDelegate.swift b/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVComponentDelegate.swift
index a11a4952e4..6c98a59c55 100644
--- a/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVComponentDelegate.swift
+++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController+CVComponentDelegate.swift
@@ -4,7 +4,6 @@
import Foundation
import QuickLook
-import PromiseKit
import PassKit
extension ConversationViewController: CVComponentDelegate {
diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift b/Signal/src/ViewControllers/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift
index 4bad1564a2..703b563a52 100644
--- a/Signal/src/ViewControllers/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift
+++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift
@@ -4,7 +4,6 @@
import Foundation
import Photos
-import PromiseKit
extension ConversationViewController: ConversationInputToolbarDelegate {
diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController+MessageRequest.swift b/Signal/src/ViewControllers/ConversationView/ConversationViewController+MessageRequest.swift
index a2def01ee0..a913a26478 100644
--- a/Signal/src/ViewControllers/ConversationView/ConversationViewController+MessageRequest.swift
+++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController+MessageRequest.swift
@@ -4,7 +4,6 @@
import Foundation
import SafariServices
-import PromiseKit
@objc
extension ConversationViewController: MessageRequestDelegate {
@@ -164,7 +163,7 @@ extension ConversationViewController: MessageRequestDelegate {
promises.append(networkManager.makePromise(request: request).asVoid())
}
- when(fulfilled: promises).done {
+ Promise.when(fulfilled: promises).done {
Logger.info("Successfully reported \(guidsToReport.count) message(s) from \(senderPhoneNumber) as spam.")
}.catch { error in
owsFailDebug("Failed to report message(s) from \(senderPhoneNumber) as spam with error: \(error)")
diff --git a/Signal/src/ViewControllers/ConversationView/MemberRequestView.swift b/Signal/src/ViewControllers/ConversationView/MemberRequestView.swift
index 23a9da007e..13354b56d9 100644
--- a/Signal/src/ViewControllers/ConversationView/MemberRequestView.swift
+++ b/Signal/src/ViewControllers/ConversationView/MemberRequestView.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
class MemberRequestView: UIStackView {
diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIGroupsV2.swift b/Signal/src/ViewControllers/DebugUI/DebugUIGroupsV2.swift
index a28928ef24..61ad72e54c 100644
--- a/Signal/src/ViewControllers/DebugUI/DebugUIGroupsV2.swift
+++ b/Signal/src/ViewControllers/DebugUI/DebugUIGroupsV2.swift
@@ -5,7 +5,6 @@
import Foundation
import SignalServiceKit
import SignalMessaging
-import PromiseKit
#if DEBUG
diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m
index c46fc90fb4..81bfb01c7d 100644
--- a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m
+++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m
@@ -4,8 +4,8 @@
#import "DebugUIMessagesAssetLoader.h"
#import
-#import
#import
+#import
#import
#import
#import
@@ -696,11 +696,11 @@ typedef void (^OWSImageDrawBlock)(CGContextRef context);
for (DebugUIMessagesAssetLoader *assetLoader in assetLoaders) {
// Use chained promises to make the code more readable.
- AnyPromise *promise = [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
+ AnyPromise *promise = AnyPromise.withFuture(^(AnyFuture *future) {
assetLoader.prepareBlock(
^{
// The value doesn't matter, we just need any non-NSError value.
- resolve(@(1));
+ [future resolveWithValue:@1];
},
^{
NSError *error =
@@ -710,14 +710,13 @@ typedef void (^OWSImageDrawBlock)(CGContextRef context);
@synchronized(errors) {
[errors addObject:error];
}
- resolve(error);
+ [future rejectWithError:error];
});
- }];
+ });
[promises addObject:promise];
}
- // We could use PMKJoin() or PMKWhen().
- PMKJoin(promises).then(^(id value) { success(); }).catch(^(id error) {
+ [AnyPromise whenResolved:promises].done(^(id value) { success(); }).catch(^(id error) {
OWSLogError(@"Could not prepare fake asset loaders: %@.", error);
failure();
});
diff --git a/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift b/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift
index e314a57a83..3fcbd54e93 100644
--- a/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift
+++ b/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift
@@ -5,7 +5,6 @@
import Foundation
import SignalServiceKit
import SignalMessaging
-import PromiseKit
#if DEBUG
@@ -79,10 +78,10 @@ class DebugUINotifications: DebugUIPage {
// Notifications won't sound if the app is suspended.
let taskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
- return after(seconds: kNotificationDelay).done {
+ return Guarantee.after(seconds: kNotificationDelay).done {
block()
}.then {
- after(seconds: 2.0)
+ Guarantee.after(seconds: 2.0)
}.done {
// We don't want to endBackgroundTask until *after* the notifications manager is done,
// but it dispatches async without a completion handler, so we just wait a while extra.
@@ -110,9 +109,7 @@ class DebugUINotifications: DebugUIPage {
func notifyForEverythingInSequence(contactThread: TSContactThread) -> Guarantee {
let taskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
- return firstly {
- self.notifyForIncomingCall(thread: contactThread)
- }.then {
+ return self.notifyForIncomingCall(thread: contactThread).then {
self.notifyForMissedCall(thread: contactThread)
}.then {
self.notifyForMissedCallBecauseOfNewIdentity(thread: contactThread)
diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIPayments.swift b/Signal/src/ViewControllers/DebugUI/DebugUIPayments.swift
index 935ea1710f..7b5c71ce68 100644
--- a/Signal/src/ViewControllers/DebugUI/DebugUIPayments.swift
+++ b/Signal/src/ViewControllers/DebugUI/DebugUIPayments.swift
@@ -5,7 +5,6 @@
import Foundation
import SignalServiceKit
import SignalMessaging
-import PromiseKit
#if DEBUG
diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIStress.swift b/Signal/src/ViewControllers/DebugUI/DebugUIStress.swift
index 881e994cad..f8de3caf72 100644
--- a/Signal/src/ViewControllers/DebugUI/DebugUIStress.swift
+++ b/Signal/src/ViewControllers/DebugUI/DebugUIStress.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
#if DEBUG
diff --git a/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m
index 4958b2f274..338776f406 100644
--- a/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m
+++ b/Signal/src/ViewControllers/DebugUI/DebugUISyncMessages.m
@@ -6,7 +6,6 @@
#import "DebugUIContacts.h"
#import "Signal-Swift.h"
#import "ThreadUtil.h"
-#import
#import
#import
#import
diff --git a/Signal/src/ViewControllers/ForwardMessageViewController.swift b/Signal/src/ViewControllers/ForwardMessageViewController.swift
index 13c035b935..1132cb04a6 100644
--- a/Signal/src/ViewControllers/ForwardMessageViewController.swift
+++ b/Signal/src/ViewControllers/ForwardMessageViewController.swift
@@ -2,8 +2,6 @@
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
-import PromiseKit
-
public protocol ForwardMessageDelegate: AnyObject {
func forwardMessageFlowDidComplete(items: [ForwardMessageItem],
recipientThreads: [TSThread])
@@ -296,7 +294,7 @@ extension ForwardMessageViewController {
self.send(item: item, toRecipientThreads: recipientThreads)
}
return firstly(on: .main) { () -> Promise in
- when(resolved: promises).asVoid()
+ Promise.when(resolved: promises).asVoid()
}.then(on: .main) { _ -> Promise in
// The user may have added an additional text message to the forward.
// It should be sent last.
@@ -419,7 +417,7 @@ extension ForwardMessageViewController {
enqueueBlock: @escaping (RecipientThread) -> Promise) -> Promise {
AssertIsOnMainThread()
- return when(fulfilled: recipientThreads.map { thread in enqueueBlock(thread) }).asVoid()
+ return Promise.when(fulfilled: recipientThreads.map { thread in enqueueBlock(thread) }).asVoid()
}
fileprivate func recipientThreads(for conversationItems: [ConversationItem]) -> Promise<[RecipientThread]> {
diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift
index 7ad5cd99d9..6ab4d0e300 100644
--- a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift
+++ b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import SignalMessaging
import YYImage
@@ -108,7 +107,7 @@ class GifPickerCell: UICollectionViewCell {
return Promise(error: GiphyError.assertionError(description: "fullSizeAsset was unexpectedly nil"))
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
// We don't retain a handle on the asset request, since there will only ever
// be one selected asset, and we never want to cancel it.
@@ -116,13 +115,13 @@ class GifPickerCell: UICollectionViewCell {
assetDescription: fullSizeAsset,
priority: .high,
success: { _, asset in
- resolver.fulfill(asset)
+ future.resolve(asset)
},
failure: { _ in
// TODO GiphyDownloader API should pass through a useful failing error
// so we can pass it through here
Logger.error("request failed")
- resolver.reject(GiphyError.fetchFailure)
+ future.reject(GiphyError.fetchFailure)
})
return promise
diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift
index 1bde848e1e..cc0c3023a4 100644
--- a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift
+++ b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift
@@ -5,7 +5,6 @@
import Foundation
import SignalServiceKit
import SignalMessaging
-import PromiseKit
@objc
public class GifPickerNavigationViewController: OWSNavigationController {
diff --git a/Signal/src/ViewControllers/GroupInviteLinksUI.swift b/Signal/src/ViewControllers/GroupInviteLinksUI.swift
index 644dcbe63e..5693a2766d 100644
--- a/Signal/src/ViewControllers/GroupInviteLinksUI.swift
+++ b/Signal/src/ViewControllers/GroupInviteLinksUI.swift
@@ -4,7 +4,6 @@
import Foundation
import UIKit
-import PromiseKit
@objc
public class GroupInviteLinksUI: UIView {
diff --git a/Signal/src/ViewControllers/GroupLinkPromotionActionSheet.swift b/Signal/src/ViewControllers/GroupLinkPromotionActionSheet.swift
index ac567e41eb..a2d874f4d1 100644
--- a/Signal/src/ViewControllers/GroupLinkPromotionActionSheet.swift
+++ b/Signal/src/ViewControllers/GroupLinkPromotionActionSheet.swift
@@ -4,7 +4,6 @@
import Foundation
import UIKit
-import PromiseKit
class CustomActionSheet: ActionSheetController {
public override func viewWillDisappear(_ animated: Bool) {
diff --git a/Signal/src/ViewControllers/GroupMigrationActionSheet.swift b/Signal/src/ViewControllers/GroupMigrationActionSheet.swift
index 50ecd8ee93..5c47912948 100644
--- a/Signal/src/ViewControllers/GroupMigrationActionSheet.swift
+++ b/Signal/src/ViewControllers/GroupMigrationActionSheet.swift
@@ -4,7 +4,6 @@
import Foundation
import UIKit
-import PromiseKit
@objc
public class GroupMigrationActionSheet: UIView {
diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m
index 41e16600d9..d305e7f6a6 100644
--- a/Signal/src/ViewControllers/HomeView/HomeViewController.m
+++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m
@@ -11,8 +11,8 @@
#import "TSAccountManager.h"
#import "TSGroupThread.h"
#import "ViewControllerUtils.h"
-#import
#import
+#import
#import
#import
#import
@@ -773,9 +773,9 @@ NSString *const kArchiveButtonPseudoGroup = @"kArchiveButtonPseudoGroup";
OWSLogInfo(@"beggining refreshing.");
[self.messageFetcherJob runObjc]
- .then(^{
+ .then(^(id value) {
if (TSAccountManager.shared.isRegisteredPrimaryDevice) {
- return [AnyPromise promiseWithValue:nil];
+ return [AnyPromise promiseWithValue:@1];
}
return [SSKEnvironment.shared.syncManager sendAllSyncRequestMessagesWithTimeout:20];
diff --git a/Signal/src/ViewControllers/LoadingViewController.swift b/Signal/src/ViewControllers/LoadingViewController.swift
index bd0b42fc98..80f111e555 100644
--- a/Signal/src/ViewControllers/LoadingViewController.swift
+++ b/Signal/src/ViewControllers/LoadingViewController.swift
@@ -1,9 +1,8 @@
//
-// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
+// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
import Foundation
-import PromiseKit
// The initial presentation is intended to be indistinguishable from the Launch Screen.
// After a delay we present some "loading" UI so the user doesn't think the app is frozen.
diff --git a/Signal/src/ViewControllers/LocationPicker.swift b/Signal/src/ViewControllers/LocationPicker.swift
index 75ec0416ee..3d7e4ff494 100644
--- a/Signal/src/ViewControllers/LocationPicker.swift
+++ b/Signal/src/ViewControllers/LocationPicker.swift
@@ -10,7 +10,6 @@
import UIKit
import MapKit
import CoreLocation
-import PromiseKit
@objc
public protocol LocationPickerDelegate {
@@ -428,7 +427,7 @@ public class Location: NSObject {
}
public func generateSnapshot() -> Promise {
- return Promise { resolver in
+ return Promise { future in
let options = MKMapSnapshotter.Options()
// this is the plus/minus meter range from the given coordinate
@@ -445,12 +444,12 @@ public class Location: NSObject {
MKMapSnapshotter(options: options).start(with: .global()) { snapshot, error in
guard error == nil else {
owsFailDebug("Unexpectedly failed to capture map snapshot \(error!)")
- return resolver.reject(LocationError.assertion)
+ return future.reject(LocationError.assertion)
}
guard let snapshot = snapshot else {
owsFailDebug("snapshot unexpectedly nil")
- return resolver.reject(LocationError.assertion)
+ return future.reject(LocationError.assertion)
}
// Draw our location pin on the snapshot
@@ -477,10 +476,10 @@ public class Location: NSObject {
guard let finalImage = image else {
owsFailDebug("image unexpectedly nil")
- return resolver.reject(LocationError.assertion)
+ return future.reject(LocationError.assertion)
}
- resolver.fulfill(finalImage)
+ future.resolve(finalImage)
}
}
}
diff --git a/Signal/src/ViewControllers/MediaGallery/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaGallery/MediaPageViewController.swift
index d1a49cdbbc..5ff7d297ce 100644
--- a/Signal/src/ViewControllers/MediaGallery/MediaPageViewController.swift
+++ b/Signal/src/ViewControllers/MediaGallery/MediaPageViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
// Objc wrapper for the MediaGalleryItem struct
@objc
diff --git a/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift b/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift
index 93f8db2f7f..97009782c8 100644
--- a/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift
+++ b/Signal/src/ViewControllers/MediaGallery/Transitions/MediaDismissAnimationController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
class MediaDismissAnimationController: NSObject {
private let item: Media
diff --git a/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift b/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift
index 9afb4b62b9..32d321f316 100644
--- a/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift
+++ b/Signal/src/ViewControllers/NewGroupView/BaseGroupMemberViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol GroupMemberViewDelegate: AnyObject {
var groupMemberViewRecipientSet: OrderedSet { get }
@@ -356,10 +355,10 @@ extension BaseGroupMemberViewController: RecipientPickerDelegate {
let address = recipient.address,
!GroupManager.doesUserHaveAnnouncementOnlyGroupsCapability(address: address,
transaction: transaction) {
-
+
// Re-fetch profile for this user.
ProfileFetcherJob.fetchProfile(address: address, ignoreThrottling: true)
-
+
return .memberHasOutdatedClient
}
return .canBeSelected
diff --git a/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift b/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift
index 88d4b5c680..5a784ded2f 100644
--- a/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift
+++ b/Signal/src/ViewControllers/NewGroupView/NewGroupConfirmViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SafariServices
@objc
diff --git a/Signal/src/ViewControllers/OWSPinSetupViewController.swift b/Signal/src/ViewControllers/OWSPinSetupViewController.swift
index c225f860b5..106eb6917c 100644
--- a/Signal/src/ViewControllers/OWSPinSetupViewController.swift
+++ b/Signal/src/ViewControllers/OWSPinSetupViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
import SafariServices
@objc(OWSPinSetupViewController)
@@ -693,7 +692,7 @@ extension PinSetupViewController {
return showRegistrationLockConfirmation(fromViewController: fromViewController)
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
let actionSheet = ActionSheetController(
title: NSLocalizedString("PIN_CREATION_DISABLE_CONFIRMATION_TITLE",
@@ -703,7 +702,7 @@ extension PinSetupViewController {
)
let cancelAction = ActionSheetAction(title: CommonStrings.cancelButton, style: .cancel) { _ in
- resolver.fulfill(false)
+ future.resolve(false)
}
actionSheet.addAction(cancelAction)
@@ -720,7 +719,7 @@ extension PinSetupViewController {
KeyBackupService.useDeviceLocalMasterKey(transaction: transaction)
transaction.addAsyncCompletionOnMain {
- modal.dismiss { resolver.fulfill(true) }
+ modal.dismiss { future.resolve(true) }
}
}
}
@@ -733,7 +732,7 @@ extension PinSetupViewController {
}
private class func showRegistrationLockConfirmation(fromViewController: UIViewController) -> Promise {
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
let actionSheet = ActionSheetController(
title: NSLocalizedString("PIN_CREATION_REGLOCK_CONFIRMATION_TITLE",
@@ -743,7 +742,7 @@ extension PinSetupViewController {
)
let cancelAction = ActionSheetAction(title: CommonStrings.cancelButton, style: .cancel) { _ in
- resolver.fulfill(false)
+ future.resolve(false)
}
actionSheet.addAction(cancelAction)
@@ -757,15 +756,15 @@ extension PinSetupViewController {
canCancel: false
) { modal in
OWS2FAManager.shared.disableRegistrationLockV2().then {
- Promise { resolver in
- modal.dismiss { resolver.fulfill(()) }
+ Guarantee { resolve in
+ modal.dismiss { resolve(()) }
}
}.then { () -> Promise in
disablePinWithConfirmation(fromViewController: fromViewController)
}.done { success in
- resolver.fulfill(success)
+ future.resolve(success)
}.catch { error in
- modal.dismiss { resolver.reject(error) }
+ modal.dismiss { future.reject(error) }
}
}
}
diff --git a/Signal/src/ViewControllers/Payments/SendPaymentCompletionActionSheet.swift b/Signal/src/ViewControllers/Payments/SendPaymentCompletionActionSheet.swift
index 41b7c00776..f68c756e40 100644
--- a/Signal/src/ViewControllers/Payments/SendPaymentCompletionActionSheet.swift
+++ b/Signal/src/ViewControllers/Payments/SendPaymentCompletionActionSheet.swift
@@ -4,7 +4,6 @@
import Foundation
import UIKit
-import PromiseKit
import Lottie
@objc
diff --git a/Signal/src/ViewControllers/Payments/SendPaymentHelper.swift b/Signal/src/ViewControllers/Payments/SendPaymentHelper.swift
index b27dac31a5..41dd29fb23 100644
--- a/Signal/src/ViewControllers/Payments/SendPaymentHelper.swift
+++ b/Signal/src/ViewControllers/Payments/SendPaymentHelper.swift
@@ -4,7 +4,6 @@
import Foundation
import UIKit
-import PromiseKit
public struct SendPaymentInfo {
let recipient: SendPaymentRecipient
diff --git a/Signal/src/ViewControllers/Payments/SendPaymentViewController.swift b/Signal/src/ViewControllers/Payments/SendPaymentViewController.swift
index 84cadd8c67..bddf51ee4f 100644
--- a/Signal/src/ViewControllers/Payments/SendPaymentViewController.swift
+++ b/Signal/src/ViewControllers/Payments/SendPaymentViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
import Lottie
@objc
diff --git a/Signal/src/ViewControllers/Photos/ImagePickerController.swift b/Signal/src/ViewControllers/Photos/ImagePickerController.swift
index 09955a6079..563b133930 100644
--- a/Signal/src/ViewControllers/Photos/ImagePickerController.swift
+++ b/Signal/src/ViewControllers/Photos/ImagePickerController.swift
@@ -4,7 +4,6 @@
import Foundation
import Photos
-import PromiseKit
protocol ImagePickerGridControllerDelegate: AnyObject {
func imagePickerDidCompleteSelection(_ imagePicker: ImagePickerGridController)
diff --git a/Signal/src/ViewControllers/Photos/PhotoCapture.swift b/Signal/src/ViewControllers/Photos/PhotoCapture.swift
index 5fdc949059..46f0b9e30a 100644
--- a/Signal/src/ViewControllers/Photos/PhotoCapture.swift
+++ b/Signal/src/ViewControllers/Photos/PhotoCapture.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol PhotoCaptureDelegate: AnyObject {
@@ -862,9 +861,9 @@ class MovieRecording {
state = .finished
audioInput.markAsFinished()
videoInput.markAsFinished()
- return Promise { resolver -> Void in
+ return Promise { future -> Void in
self.assetWriter.finishWriting {
- resolver.fulfill(self.assetWriter.outputURL)
+ future.resolve(self.assetWriter.outputURL)
}
}
default:
diff --git a/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift b/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift
index 9d43365f0e..7d4aa0e7ac 100644
--- a/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift
+++ b/Signal/src/ViewControllers/Photos/PhotoCaptureViewController.swift
@@ -4,7 +4,6 @@
import Foundation
import AVFoundation
-import PromiseKit
import Lottie
protocol PhotoCaptureViewControllerDelegate: AnyObject {
diff --git a/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift b/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift
index 1605508e5e..5e9e998928 100644
--- a/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift
+++ b/Signal/src/ViewControllers/Photos/PhotoCollectionPickerController.swift
@@ -1,10 +1,9 @@
//
-// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
+// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
import Foundation
import Photos
-import PromiseKit
protocol PhotoCollectionPickerDelegate: AnyObject {
func photoCollectionPicker(_ photoCollectionPicker: PhotoCollectionPickerController, didPickCollection collection: PhotoCollection)
diff --git a/Signal/src/ViewControllers/Photos/PhotoLibrary.swift b/Signal/src/ViewControllers/Photos/PhotoLibrary.swift
index 09d2ab68e3..e90aa6ea7c 100644
--- a/Signal/src/ViewControllers/Photos/PhotoLibrary.swift
+++ b/Signal/src/ViewControllers/Photos/PhotoLibrary.swift
@@ -4,7 +4,6 @@
import Foundation
import Photos
-import PromiseKit
protocol PhotoLibraryDelegate: AnyObject {
func photoLibraryDidChange(_ photoLibrary: PhotoLibrary)
@@ -141,7 +140,7 @@ class PhotoCollectionContents {
}
private func requestImageDataSource(for asset: PHAsset) -> Promise<(dataSource: DataSource, dataUTI: String)> {
- return Promise { resolver in
+ return Promise { future in
let options: PHImageRequestOptions = PHImageRequestOptions()
options.isNetworkAccessAllowed = true
@@ -151,27 +150,27 @@ class PhotoCollectionContents {
_ = imageManager.requestImageData(for: asset, options: options) { imageData, dataUTI, _, _ in
guard let imageData = imageData else {
- resolver.reject(PhotoLibraryError.assertionError(description: "imageData was unexpectedly nil"))
+ future.reject(PhotoLibraryError.assertionError(description: "imageData was unexpectedly nil"))
return
}
guard let dataUTI = dataUTI else {
- resolver.reject(PhotoLibraryError.assertionError(description: "dataUTI was unexpectedly nil"))
+ future.reject(PhotoLibraryError.assertionError(description: "dataUTI was unexpectedly nil"))
return
}
guard let dataSource = DataSourceValue.dataSource(with: imageData, utiType: dataUTI) else {
- resolver.reject(PhotoLibraryError.assertionError(description: "dataSource was unexpectedly nil"))
+ future.reject(PhotoLibraryError.assertionError(description: "dataSource was unexpectedly nil"))
return
}
- resolver.fulfill((dataSource: dataSource, dataUTI: dataUTI))
+ future.resolve((dataSource: dataSource, dataUTI: dataUTI))
}
}
}
private func requestVideoDataSource(for asset: PHAsset) -> Promise {
- return Promise { resolver in
+ return Promise { future in
let options: PHVideoRequestOptions = PHVideoRequestOptions()
options.isNetworkAccessAllowed = true
@@ -180,7 +179,7 @@ class PhotoCollectionContents {
_ = imageManager.requestAVAsset(forVideo: asset, options: options) { video, _, info in
guard let video = video else {
let error = info?[PHImageErrorKey] as! Error?
- resolver.reject(PhotoLibraryError.failedToExportAsset(underlyingError: error))
+ future.reject(PhotoLibraryError.failedToExportAsset(underlyingError: error))
return
}
@@ -192,7 +191,7 @@ class PhotoCollectionContents {
if let dataSource = try? DataSourcePath.dataSource(with: url, shouldDeleteOnDeallocation: false) {
if !SignalAttachment.isVideoThatNeedsCompression(dataSource: dataSource, dataUTI: dataUTI) {
- resolver.fulfill(SignalAttachment.attachment(dataSource: dataSource, dataUTI: dataUTI))
+ future.resolve(SignalAttachment.attachment(dataSource: dataSource, dataUTI: dataUTI))
return
}
}
@@ -206,7 +205,9 @@ class PhotoCollectionContents {
let (compressPromise, _) = SignalAttachment.compressVideoAsMp4(asset: video,
baseFilename: baseFilename,
dataUTI: dataUTI)
- compressPromise.pipe { resolver.resolve($0) }
+ compressPromise
+ .done { future.resolve($0) }
+ .catch { future.reject($0) }
}
}
}
diff --git a/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift b/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift
index 42704c707a..1396b78ae0 100644
--- a/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift
+++ b/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift
@@ -4,7 +4,6 @@
import Foundation
import Photos
-import PromiseKit
@objc
protocol SendMediaNavDelegate: AnyObject {
@@ -551,9 +550,9 @@ extension SendMediaNavigationController: ImagePickerGridControllerDelegate {
func showApprovalAfterProcessingAnyMediaLibrarySelections() {
let backgroundBlock: (ModalActivityIndicatorViewController) -> Void = { modal in
- let approvalItemsPromise = when(fulfilled: self.attachmentDraftCollection.attachmentApprovalItemPromises)
+ let approvalItemsPromise: Promise<[AttachmentApprovalItem]> = Promise.when(fulfilled: self.attachmentDraftCollection.attachmentApprovalItemPromises)
firstly { () -> Promise> in
- return race(
+ return Promise.race(
approvalItemsPromise.map { attachmentApprovalItems -> Swift.Result<[AttachmentApprovalItem], Error> in
Swift.Result.success(attachmentApprovalItems)
},
diff --git a/Signal/src/ViewControllers/RecipientPicker/AddToBlockListViewController.swift b/Signal/src/ViewControllers/RecipientPicker/AddToBlockListViewController.swift
index a39762b91c..ca3fc47de6 100644
--- a/Signal/src/ViewControllers/RecipientPicker/AddToBlockListViewController.swift
+++ b/Signal/src/ViewControllers/RecipientPicker/AddToBlockListViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
protocol AddToBlockListDelegate: AnyObject {
diff --git a/Signal/src/ViewControllers/RecipientPicker/ComposeViewController.swift b/Signal/src/ViewControllers/RecipientPicker/ComposeViewController.swift
index 72b26cfbe4..f83650fcd2 100644
--- a/Signal/src/ViewControllers/RecipientPicker/ComposeViewController.swift
+++ b/Signal/src/ViewControllers/RecipientPicker/ComposeViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
class ComposeViewController: OWSViewController {
diff --git a/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift b/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift
index 8e8977c1c7..b3cf5df686 100644
--- a/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift
+++ b/Signal/src/ViewControllers/RecipientPicker/RecipientPickerDelegate.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public enum RecipientPickerRecipientState: Int {
diff --git a/Signal/src/ViewControllers/RecipientPicker/RecipientPickerViewController.m b/Signal/src/ViewControllers/RecipientPicker/RecipientPickerViewController.m
index 46953a942c..2b9ce39de4 100644
--- a/Signal/src/ViewControllers/RecipientPicker/RecipientPickerViewController.m
+++ b/Signal/src/ViewControllers/RecipientPicker/RecipientPickerViewController.m
@@ -8,7 +8,7 @@
#import "SignalApp.h"
#import "UIView+OWS.h"
#import
-#import
+#import
#import
#import
#import
@@ -184,9 +184,9 @@ const NSUInteger kMinimumSearchLength = 1;
OWSLogInfo(@"beggining refreshing.");
[self.contactsManagerImpl userRequestedSystemContactsRefresh]
- .then(^{
+ .then(^(id value) {
if (TSAccountManager.shared.isRegisteredPrimaryDevice) {
- return [AnyPromise promiseWithValue:nil];
+ return [AnyPromise promiseWithValue:@1];
}
return [SSKEnvironment.shared.syncManager sendAllSyncRequestMessagesWithTimeout:20];
diff --git a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift
index b1ce398e70..b05086ac7b 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
public class OnboardingBaseViewController: OWSViewController {
diff --git a/Signal/src/ViewControllers/Registration/OnboardingController.swift b/Signal/src/ViewControllers/Registration/OnboardingController.swift
index a66b2a7989..0ffb613b53 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
public class OnboardingCountryState: NSObject {
diff --git a/Signal/src/ViewControllers/Registration/OnboardingDroppedYdbViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingDroppedYdbViewController.swift
index 2b0165c397..eea446dad4 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingDroppedYdbViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingDroppedYdbViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
public class OnboardingDroppedYdbViewController: OnboardingBaseViewController {
diff --git a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift
index 13435b54c3..86602f2a0f 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
import Contacts
import Lottie
@@ -83,7 +82,7 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController {
private func requestContactsAccess() -> Promise {
Logger.info("")
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
CNContactStore().requestAccess(for: CNEntityType.contacts) { (granted, error) -> Void in
if granted {
Logger.info("Granted.")
@@ -91,7 +90,7 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController {
Logger.error("Error: \(String(describing: error)).")
}
// Always fulfill.
- resolver.fulfill(())
+ future.resolve()
}
return promise
}
diff --git a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberDiscoverabilityViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberDiscoverabilityViewController.swift
index cc5ba0a3df..47ee678108 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberDiscoverabilityViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberDiscoverabilityViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
public class OnboardingPhoneNumberDiscoverabilityViewController: OnboardingBaseViewController {
diff --git a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift
index b0cdeb2a71..bd85053812 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
@objc
public class OnboardingPhoneNumberViewController: OnboardingBaseViewController {
diff --git a/Signal/src/ViewControllers/Registration/OnboardingProfileCreationViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingProfileCreationViewController.swift
index 811e92b7b4..86da2dc90c 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingProfileCreationViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingProfileCreationViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class OnboardingProfileCreationViewController: OnboardingBaseViewController {
diff --git a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift
index ff70703f6f..ae2078bf53 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
import SafariServices
@objc
diff --git a/Signal/src/ViewControllers/Registration/OnboardingVerificationViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingVerificationViewController.swift
index 85a286782a..3f8203d14b 100644
--- a/Signal/src/ViewControllers/Registration/OnboardingVerificationViewController.swift
+++ b/Signal/src/ViewControllers/Registration/OnboardingVerificationViewController.swift
@@ -3,7 +3,6 @@
//
import UIKit
-import PromiseKit
private protocol OnboardingCodeViewTextFieldDelegate: AnyObject {
func textFieldDidDeletePrevious()
diff --git a/Signal/src/ViewControllers/Registration/SecondaryLinking/ProvisioningController.swift b/Signal/src/ViewControllers/Registration/SecondaryLinking/ProvisioningController.swift
index b58cbfc9e3..4585ba1ba8 100644
--- a/Signal/src/ViewControllers/Registration/SecondaryLinking/ProvisioningController.swift
+++ b/Signal/src/ViewControllers/Registration/SecondaryLinking/ProvisioningController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class ProvisioningController: NSObject {
@@ -14,17 +13,17 @@ public class ProvisioningController: NSObject {
let provisioningSocket: ProvisioningSocket
var deviceIdPromise: Promise
- var deviceIdResolver: Resolver
+ var deviceIdFuture: Future
var provisionEnvelopePromise: Promise
- var provisionEnvelopeResolver: Resolver
+ var provisionEnvelopeFuture: Future
public init(onboardingController: OnboardingController) {
self.onboardingController = onboardingController
provisioningCipher = ProvisioningCipher.generate()
- (self.deviceIdPromise, self.deviceIdResolver) = Promise.pending()
- (self.provisionEnvelopePromise, self.provisionEnvelopeResolver) = Promise.pending()
+ (self.deviceIdPromise, self.deviceIdFuture) = Promise.pending()
+ (self.provisionEnvelopePromise, self.provisionEnvelopeFuture) = Promise.pending()
provisioningSocket = ProvisioningSocket()
@@ -35,8 +34,8 @@ public class ProvisioningController: NSObject {
public func resetPromises() {
_awaitProvisionMessage = nil
- (self.deviceIdPromise, self.deviceIdResolver) = Promise.pending()
- (self.provisionEnvelopePromise, self.provisionEnvelopeResolver) = Promise.pending()
+ (self.deviceIdPromise, self.deviceIdFuture) = Promise.pending()
+ (self.provisionEnvelopePromise, self.provisionEnvelopeFuture) = Promise.pending()
}
@objc
@@ -71,8 +70,8 @@ public class ProvisioningController: NSObject {
navigationController: UINavigationController) {
awaitProvisionMessage.done { [weak self, weak navigationController] message in
- guard let self = self else { throw PMKError.cancelled }
- guard let navigationController = navigationController else { throw PMKError.cancelled }
+ guard let self = self else { throw PromiseError.cancelled }
+ guard let navigationController = navigationController else { throw PromiseError.cancelled }
// Verify the primary device is new enough to link us. Right now this is a simple check
// of >= the latest version, but when we bump the version we may need to be more specific
@@ -96,7 +95,7 @@ public class ProvisioningController: NSObject {
navigationController.pushViewController(confirmVC, animated: true)
}.catch { error in
switch error {
- case PMKError.cancelled:
+ case PromiseError.cancelled:
Logger.info("cancelled")
default:
Logger.warn("error: \(error)")
@@ -183,7 +182,7 @@ public class ProvisioningController: NSObject {
public func getProvisioningURL() -> Promise {
return getDeviceId().map { [weak self] deviceId in
- guard let self = self else { throw PMKError.cancelled }
+ guard let self = self else { throw PromiseError.cancelled }
return try self.buildProvisioningUrl(deviceId: deviceId)
}
@@ -193,7 +192,7 @@ public class ProvisioningController: NSObject {
public var awaitProvisionMessage: Promise {
if _awaitProvisionMessage == nil {
_awaitProvisionMessage = provisionEnvelopePromise.map { [weak self] envelope in
- guard let self = self else { throw PMKError.cancelled }
+ guard let self = self else { throw PromiseError.cancelled }
return try self.provisioningCipher.decrypt(envelope: envelope)
}
}
@@ -202,7 +201,7 @@ public class ProvisioningController: NSObject {
public func completeLinking(deviceName: String) -> Promise {
return awaitProvisionMessage.then { [weak self] provisionMessage -> Promise in
- guard let self = self else { throw PMKError.cancelled }
+ guard let self = self else { throw PromiseError.cancelled }
return self.accountManager.completeSecondaryLinking(provisionMessage: provisionMessage,
deviceName: deviceName)
@@ -249,20 +248,20 @@ public class ProvisioningController: NSObject {
extension ProvisioningController: ProvisioningSocketDelegate {
public func provisioningSocket(_ provisioningSocket: ProvisioningSocket, didReceiveDeviceId deviceId: String) {
- assert(deviceIdPromise.isPending)
- deviceIdResolver.fulfill(deviceId)
+ owsAssertDebug(!deviceIdPromise.isSealed)
+ deviceIdFuture.resolve(deviceId)
}
public func provisioningSocket(_ provisioningSocket: ProvisioningSocket, didReceiveEnvelope envelope: ProvisioningProtoProvisionEnvelope) {
// After receiving the provisioning message, there's nothing else to retreive from the provisioning socket
provisioningSocket.disconnect()
- assert(provisionEnvelopePromise.isPending)
- return provisionEnvelopeResolver.fulfill(envelope)
+ owsAssertDebug(!provisionEnvelopePromise.isSealed)
+ return provisionEnvelopeFuture.resolve(envelope)
}
public func provisioningSocket(_ provisioningSocket: ProvisioningSocket, didError error: Error) {
- deviceIdResolver.reject(error)
- provisionEnvelopeResolver.reject(error)
+ deviceIdFuture.reject(error)
+ provisionEnvelopeFuture.reject(error)
}
}
diff --git a/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingPrepViewController.swift b/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingPrepViewController.swift
index 0483e30b6e..3853724280 100644
--- a/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingPrepViewController.swift
+++ b/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingPrepViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import Lottie
@objc
diff --git a/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingSetDeviceNameViewController.swift b/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingSetDeviceNameViewController.swift
index 2d12c26a8e..94252d7ebd 100644
--- a/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingSetDeviceNameViewController.swift
+++ b/Signal/src/ViewControllers/Registration/SecondaryLinking/SecondaryLinkingSetDeviceNameViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
class SecondaryLinkingSetDeviceNameViewController: OnboardingBaseViewController {
diff --git a/Signal/src/ViewControllers/SendMessageFlow.swift b/Signal/src/ViewControllers/SendMessageFlow.swift
index 421afcb6a9..46c783c075 100644
--- a/Signal/src/ViewControllers/SendMessageFlow.swift
+++ b/Signal/src/ViewControllers/SendMessageFlow.swift
@@ -2,8 +2,6 @@
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
-import PromiseKit
-
@objc
public protocol SendMessageDelegate: AnyObject {
func sendMessageFlowDidComplete(threads: [TSThread])
diff --git a/Signal/src/ViewControllers/ThreadSettings/AddGroupMembersViewController.swift b/Signal/src/ViewControllers/ThreadSettings/AddGroupMembersViewController.swift
index f1ea70ecbf..0466af5a94 100644
--- a/Signal/src/ViewControllers/ThreadSettings/AddGroupMembersViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/AddGroupMembersViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol AddGroupMembersViewControllerDelegate: AnyObject {
func addGroupMembersViewDidUpdate()
diff --git a/Signal/src/ViewControllers/ThreadSettings/AddToGroupViewController.swift b/Signal/src/ViewControllers/ThreadSettings/AddToGroupViewController.swift
index 4852700eb0..84d69b229a 100644
--- a/Signal/src/ViewControllers/ThreadSettings/AddToGroupViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/AddToGroupViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class AddToGroupViewController: OWSTableViewController2 {
diff --git a/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift b/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift
index b1e6038a24..71c0aa1df3 100644
--- a/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/ConversationInternalViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class ConversationInternalViewController: OWSTableViewController2 {
diff --git a/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController+LegacyGroups.swift b/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController+LegacyGroups.swift
index d317963990..17949f081d 100644
--- a/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController+LegacyGroups.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController+LegacyGroups.swift
@@ -1,10 +1,9 @@
//
-// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
+// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
import Foundation
import UIKit
-import PromiseKit
class LegacyGroupView: UIView {
diff --git a/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController.swift b/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController.swift
index c418be9be1..d9d48ca3b8 100644
--- a/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/ConversationSettingsViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import UIKit
import ContactsUI
diff --git a/Signal/src/ViewControllers/ThreadSettings/DisappearingMessagesTimerSettingsViewController.swift b/Signal/src/ViewControllers/ThreadSettings/DisappearingMessagesTimerSettingsViewController.swift
index fbaf57b733..07cc7d28fb 100644
--- a/Signal/src/ViewControllers/ThreadSettings/DisappearingMessagesTimerSettingsViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/DisappearingMessagesTimerSettingsViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
class DisappearingMessagesTimerSettingsViewController: OWSTableViewController2 {
let thread: TSThread?
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupAttributesEditorHelper.swift b/Signal/src/ViewControllers/ThreadSettings/GroupAttributesEditorHelper.swift
index 73d4f032eb..cc288c7620 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupAttributesEditorHelper.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupAttributesEditorHelper.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import UIKit
protocol GroupAttributesEditorHelperDelegate: AnyObject {
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupAttributesViewController.swift b/Signal/src/ViewControllers/ThreadSettings/GroupAttributesViewController.swift
index 72a55d0841..071b10bbc3 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupAttributesViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupAttributesViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import UIKit
protocol GroupAttributesViewControllerDelegate: AnyObject {
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupLinkViewController.swift b/Signal/src/ViewControllers/ThreadSettings/GroupLinkViewController.swift
index 60975c05f8..0235edbef1 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupLinkViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupLinkViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol GroupLinkViewControllerDelegate: AnyObject {
func groupLinkViewViewDidUpdate()
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupMemberRequestsAndInvitesViewController.swift b/Signal/src/ViewControllers/ThreadSettings/GroupMemberRequestsAndInvitesViewController.swift
index 9c3eacdb23..04a9fef710 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupMemberRequestsAndInvitesViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupMemberRequestsAndInvitesViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol GroupMemberRequestsAndInvitesViewControllerDelegate: AnyObject {
func requestsAndInvitesViewDidUpdate()
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupPermissionsSettingsViewController.swift b/Signal/src/ViewControllers/ThreadSettings/GroupPermissionsSettingsViewController.swift
index 9b5c6258d0..e610004c92 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupPermissionsSettingsViewController.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupPermissionsSettingsViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
protocol GroupPermissionsSettingsDelegate: AnyObject {
func groupPermissionSettingsDidUpdate()
@@ -64,7 +63,7 @@ class GroupPermissionsSettingsViewController: OWSTableViewController2 {
let promises = membersWithoutCapability.map { address in
ProfileFetcherJob.fetchProfilePromise(address: address, ignoreThrottling: true)
}
- return when(resolved: promises).asVoid()
+ return Promise.when(resolved: promises).asVoid()
}.done { [weak self] in
self?.updateAnnouncementOnlyCapabilityState()
}.catch { error in
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper+MemberActionSheet.swift b/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper+MemberActionSheet.swift
index ee891543dd..3518218070 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper+MemberActionSheet.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper+MemberActionSheet.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
extension GroupViewHelper {
diff --git a/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper.swift b/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper.swift
index 60ffe2d03b..40a06548b9 100644
--- a/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper.swift
+++ b/Signal/src/ViewControllers/ThreadSettings/GroupViewHelper.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
protocol GroupViewHelperDelegate: AnyObject {
diff --git a/Signal/src/environment/PushRegistrationManager.swift b/Signal/src/environment/PushRegistrationManager.swift
index 911c6d1708..e2f95475bf 100644
--- a/Signal/src/environment/PushRegistrationManager.swift
+++ b/Signal/src/environment/PushRegistrationManager.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import PushKit
import SignalServiceKit
import SignalMessaging
@@ -26,13 +25,13 @@ public enum PushRegistrationError: Error {
}
private var vanillaTokenPromise: Promise?
- private var vanillaTokenResolver: Resolver?
+ private var vanillaTokenFuture: Future?
private var voipRegistry: PKPushRegistry?
private var voipTokenPromise: Promise?
- private var voipTokenResolver: Resolver?
+ private var voipTokenFuture: Future?
- public var preauthChallengeResolver: Resolver?
+ public var preauthChallengeFuture: Future?
// MARK: Public interface
@@ -60,10 +59,10 @@ public enum PushRegistrationError: Error {
public func didReceiveVanillaPreAuthChallengeToken(_ challenge: String) {
AppReadiness.runNowOrWhenAppDidBecomeReadySync {
AssertIsOnMainThread()
- if let preauthChallengeResolver = self.preauthChallengeResolver {
+ if let preauthChallengeFuture = self.preauthChallengeFuture {
Logger.info("received vanilla preauth challenge")
- preauthChallengeResolver.fulfill(challenge)
- self.preauthChallengeResolver = nil
+ preauthChallengeFuture.resolve(challenge)
+ self.preauthChallengeFuture = nil
}
}
}
@@ -71,23 +70,23 @@ public enum PushRegistrationError: Error {
// Vanilla push token is obtained from the system via AppDelegate
@objc
public func didReceiveVanillaPushToken(_ tokenData: Data) {
- guard let vanillaTokenResolver = self.vanillaTokenResolver else {
+ guard let vanillaTokenFuture = self.vanillaTokenFuture else {
owsFailDebug("promise completion in \(#function) unexpectedly nil")
return
}
- vanillaTokenResolver.fulfill(tokenData)
+ vanillaTokenFuture.resolve(tokenData)
}
// Vanilla push token is obtained from the system via AppDelegate
@objc
public func didFailToReceiveVanillaPushToken(error: Error) {
- guard let vanillaTokenResolver = self.vanillaTokenResolver else {
+ guard let vanillaTokenFuture = self.vanillaTokenFuture else {
owsFailDebug("promise completion in \(#function) unexpectedly nil")
return
}
- vanillaTokenResolver.reject(error)
+ vanillaTokenFuture.reject(error)
}
// MARK: PKPushRegistryDelegate - voIP Push Token
@@ -100,11 +99,11 @@ public enum PushRegistrationError: Error {
if CallMessageRelay.handleVoipPayload(payload.dictionaryPayload) {
// Do nothing. This was a call message relayed from the NSE
Logger.info("Handled call message from NSE.")
- } else if let preauthChallengeResolver = self.preauthChallengeResolver,
+ } else if let preauthChallengeFuture = self.preauthChallengeFuture,
let challenge = payload.dictionaryPayload["challenge"] as? String {
Logger.info("received preauth challenge")
- preauthChallengeResolver.fulfill(challenge)
- self.preauthChallengeResolver = nil
+ preauthChallengeFuture.resolve(challenge)
+ self.preauthChallengeFuture = nil
} else {
owsAssertDebug(!FeatureFlags.notificationServiceExtension)
self.messageFetcherJob.run()
@@ -116,9 +115,9 @@ public enum PushRegistrationError: Error {
Logger.info("")
owsAssertDebug(type == .voIP)
owsAssertDebug(credentials.type == .voIP)
- guard let voipTokenResolver = self.voipTokenResolver else { return }
+ guard let voipTokenFuture = self.voipTokenFuture else { return }
- voipTokenResolver.fulfill(credentials.token)
+ voipTokenFuture.resolve(credentials.token)
}
public func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
@@ -172,15 +171,15 @@ public enum PushRegistrationError: Error {
guard self.vanillaTokenPromise == nil else {
let promise = vanillaTokenPromise!
- owsAssertDebug(promise.isPending)
+ owsAssertDebug(!promise.isSealed)
Logger.info("alreay pending promise for vanilla push token")
return promise.map { $0.hexEncodedString }
}
// No pending vanilla token yet. Create a new promise
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.vanillaTokenPromise = promise
- self.vanillaTokenResolver = resolver
+ self.vanillaTokenFuture = future
UIApplication.shared.registerForRemoteNotifications()
@@ -244,14 +243,14 @@ public enum PushRegistrationError: Error {
guard self.voipTokenPromise == nil else {
let promise = self.voipTokenPromise!
- owsAssertDebug(promise.isPending)
+ owsAssertDebug(!promise.isSealed)
return promise.map { $0?.hexEncodedString }
}
// No pending voip token yet. Create a new promise
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.voipTokenPromise = promise
- self.voipTokenResolver = resolver
+ self.voipTokenFuture = future
// We don't create the voip registry in init, because it immediately requests the voip token,
// potentially before we're ready to handle it.
@@ -259,7 +258,7 @@ public enum PushRegistrationError: Error {
guard let voipRegistry = self.voipRegistry else {
owsFailDebug("failed to initialize voipRegistry")
- resolver.reject(PushRegistrationError.assertionError(description: "failed to initialize voipRegistry"))
+ future.reject(PushRegistrationError.assertionError(description: "failed to initialize voipRegistry"))
return promise.map { _ in
// coerce expected type of returned promise - we don't really care about the value,
// since this promise has been rejected. In practice this shouldn't happen
@@ -271,7 +270,7 @@ public enum PushRegistrationError: Error {
// rather than waiting for the delegate method to be called.
if let voipTokenData = voipRegistry.pushToken(for: .voIP) {
Logger.info("using pre-registered voIP token")
- resolver.fulfill(voipTokenData)
+ future.resolve(voipTokenData)
}
return promise.map { (voipTokenData: Data?) -> String? in
diff --git a/Signal/src/util/AppUpdateNag.swift b/Signal/src/util/AppUpdateNag.swift
index a869270a31..cd3cd05a22 100644
--- a/Signal/src/util/AppUpdateNag.swift
+++ b/Signal/src/util/AppUpdateNag.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
class AppUpdateNag: NSObject {
@@ -218,15 +217,15 @@ class AppStoreVersionService: NSObject {
func fetchLatestVersion(lookupURL: URL) -> Promise {
Logger.debug("lookupURL:\(lookupURL)")
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
let task = URLSession.ephemeral.dataTask(with: lookupURL) { (data, _, networkError) in
if let networkError = networkError {
- return resolver.reject(networkError)
+ return future.reject(networkError)
}
guard let data = data else {
- resolver.reject(OWSAssertionError("Missing data."))
+ future.reject(OWSAssertionError("Missing data."))
return
}
@@ -234,13 +233,13 @@ class AppStoreVersionService: NSObject {
let decoder = JSONDecoder()
let resultSet = try decoder.decode(AppStoreLookupResultSet.self, from: data)
guard let appStoreRecord = resultSet.results.first else {
- resolver.reject(OWSAssertionError("Missing or invalid record."))
+ future.reject(OWSAssertionError("Missing or invalid record."))
return
}
- resolver.fulfill(appStoreRecord)
+ future.resolve(appStoreRecord)
} catch {
- resolver.reject(error)
+ future.reject(error)
}
}
diff --git a/Signal/src/util/ContactSupportAlert.swift b/Signal/src/util/ContactSupportAlert.swift
index 05d4bc6417..c8f7c406b7 100644
--- a/Signal/src/util/ContactSupportAlert.swift
+++ b/Signal/src/util/ContactSupportAlert.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class ContactSupportAlert: NSObject {
@@ -107,11 +106,11 @@ extension ContactSupportError: LocalizedError {
extension Pastelog {
class func uploadLog() -> Promise {
- return Promise { resolver in
- Pastelog.uploadLogs(success: resolver.fulfill,
+ return Promise { future in
+ Pastelog.uploadLogs(success: future.resolve,
failure: { localizedErrorDescription in
let error = ContactSupportError.pasteLogError(localizedDescription: localizedErrorDescription)
- resolver.reject(error)
+ future.reject(error)
})
}
}
diff --git a/Signal/src/util/Device Transfer/DeviceTransferOperation.swift b/Signal/src/util/Device Transfer/DeviceTransferOperation.swift
index 8806660e20..8e0efb8937 100644
--- a/Signal/src/util/Device Transfer/DeviceTransferOperation.swift
+++ b/Signal/src/util/Device Transfer/DeviceTransferOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import MultipeerConnectivity
class DeviceTransferOperation: OWSOperation {
@@ -11,7 +10,7 @@ class DeviceTransferOperation: OWSOperation {
let file: DeviceTransferProtoFile
let promise: Promise
- private let resolver: Resolver
+ private let future: Future
class func scheduleTransfer(file: DeviceTransferProtoFile, priority: Operation.QueuePriority = .normal) -> Promise {
let operation = DeviceTransferOperation(file: file)
@@ -30,7 +29,7 @@ class DeviceTransferOperation: OWSOperation {
private init(file: DeviceTransferProtoFile) {
self.file = file
- (self.promise, self.resolver) = Promise.pending()
+ (self.promise, self.future) = Promise.pending()
super.init()
}
@@ -38,12 +37,12 @@ class DeviceTransferOperation: OWSOperation {
override func didSucceed() {
super.didSucceed()
- resolver.fulfill(())
+ future.resolve()
}
override func didFail(error: Error) {
super.didFail(error: error)
- resolver.reject(error)
+ future.reject(error)
}
override public func run() {
diff --git a/Signal/src/util/Device Transfer/DeviceTransferService+Manifest.swift b/Signal/src/util/Device Transfer/DeviceTransferService+Manifest.swift
index 986373d7ce..ab4eb36bce 100644
--- a/Signal/src/util/Device Transfer/DeviceTransferService+Manifest.swift
+++ b/Signal/src/util/Device Transfer/DeviceTransferService+Manifest.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import MultipeerConnectivity
extension DeviceTransferService {
@@ -238,13 +237,13 @@ extension DeviceTransferService {
)
try manifestData.write(to: manifestFileURL, options: .atomic)
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
session.sendResource(at: manifestFileURL, withName: DeviceTransferService.manifestIdentifier, toPeer: newDevicePeerId) { error in
if let error = error {
- resolver.reject(error)
+ future.reject(error)
} else {
- resolver.fulfill(())
+ future.resolve()
Logger.info("Successfully sent manifest to new device.")
diff --git a/Signal/src/util/Device Transfer/DeviceTransferService.swift b/Signal/src/util/Device Transfer/DeviceTransferService.swift
index d8d9363ade..a324760d58 100644
--- a/Signal/src/util/Device Transfer/DeviceTransferService.swift
+++ b/Signal/src/util/Device Transfer/DeviceTransferService.swift
@@ -4,7 +4,6 @@
import Foundation
import MultipeerConnectivity
-import PromiseKit
protocol DeviceTransferServiceObserver: AnyObject {
func deviceTransferServiceDiscoveredNewDevice(peerId: MCPeerID, discoveryInfo: [String: String]?)
@@ -292,7 +291,7 @@ class DeviceTransferService: NSObject {
var promises = [Promise]()
- let (databasePromise, databaseResolver) = Promise.pending()
+ let (databasePromise, databaseFuture) = Promise.pending()
promises.append(databasePromise)
// Transfer the database files within a write transaction so we can be confident
@@ -301,13 +300,13 @@ class DeviceTransferService: NSObject {
// minimal amount of time.
databaseStorage.asyncWrite { _ in
do {
- try when(fulfilled: [
+ try Promise.when(fulfilled: [
DeviceTransferOperation.scheduleTransfer(file: database.database, priority: .high),
DeviceTransferOperation.scheduleTransfer(file: database.wal, priority: .high)
]).wait()
- databaseResolver.fulfill(())
+ databaseFuture.resolve()
} catch {
- databaseResolver.reject(error)
+ databaseFuture.reject(error)
}
}
@@ -315,7 +314,7 @@ class DeviceTransferService: NSObject {
promises.append(DeviceTransferOperation.scheduleTransfer(file: file))
}
- when(fulfilled: promises).done {
+ Promise.when(fulfilled: promises).done {
if !FeatureFlags.deviceTransferThrowAway {
self.tsAccountManager.wasTransferred = true
}
diff --git a/Signal/src/util/NotificationActionHandler.swift b/Signal/src/util/NotificationActionHandler.swift
index d6a3bb8dac..3cc4de276d 100644
--- a/Signal/src/util/NotificationActionHandler.swift
+++ b/Signal/src/util/NotificationActionHandler.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class NotificationActionHandler: NSObject {
@@ -225,9 +224,9 @@ public class NotificationActionHandler: NSObject {
}
private class func submitDebugLogs() -> Promise {
- Promise { resolver in
+ Promise { future in
Pastelog.submitLogs {
- resolver.fulfill(())
+ future.resolve()
}
}
}
@@ -272,13 +271,13 @@ public class NotificationActionHandler: NSObject {
guard let interaction = notificationMessage.interaction else {
return Promise(error: OWSAssertionError("missing interaction"))
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.receiptManager.markAsReadLocally(
beforeSortId: interaction.sortId,
thread: notificationMessage.thread,
hasPendingMessageRequest: notificationMessage.hasPendingMessageRequest
) {
- resolver.fulfill(())
+ future.resolve()
}
return promise
}
diff --git a/Signal/src/util/RegistrationUtils.m b/Signal/src/util/RegistrationUtils.m
index 952e851bb9..edd4b68eff 100644
--- a/Signal/src/util/RegistrationUtils.m
+++ b/Signal/src/util/RegistrationUtils.m
@@ -5,7 +5,7 @@
#import "RegistrationUtils.h"
#import "OWSNavigationController.h"
#import "Signal-Swift.h"
-#import
+#import
#import
#import
#import
@@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.accountManager requestAccountVerificationObjCWithRecipientId:phoneNumber
captchaToken:nil
isSMS:true]
- .then(^{
+ .done(^(id value) {
OWSAssertIsOnMainThread();
OWSLogInfo(@"re-registering: send verification code succeeded.");
diff --git a/Signal/src/util/SignalMe.swift b/Signal/src/util/SignalMe.swift
index 96f82fd083..2ecaec849c 100644
--- a/Signal/src/util/SignalMe.swift
+++ b/Signal/src/util/SignalMe.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
class SignalMe: NSObject {
diff --git a/Signal/src/util/Stripe.swift b/Signal/src/util/Stripe.swift
index d61c6aeb0d..c86bf3afbc 100644
--- a/Signal/src/util/Stripe.swift
+++ b/Signal/src/util/Stripe.swift
@@ -4,7 +4,6 @@
import Foundation
import PassKit
-import PromiseKit
struct Stripe: Dependencies {
static func donate(amount: NSDecimalNumber, in currencyCode: Currency.Code, for payment: PKPayment) -> Promise {
diff --git a/Signal/test/Groups/GroupsV2MigrationTest.swift b/Signal/test/Groups/GroupsV2MigrationTest.swift
index 3a618bddf4..62386dd0cd 100644
--- a/Signal/test/Groups/GroupsV2MigrationTest.swift
+++ b/Signal/test/Groups/GroupsV2MigrationTest.swift
@@ -1,10 +1,9 @@
//
-// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
+// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
import XCTest
-import PromiseKit
-//import SignalServiceKit
+// import SignalServiceKit
@testable import Signal
class GroupsV2MigrationTest: SignalBaseTest {
diff --git a/Signal/test/Models/AccountManagerTest.swift b/Signal/test/Models/AccountManagerTest.swift
index b98420bec4..1216c5bf0b 100644
--- a/Signal/test/Models/AccountManagerTest.swift
+++ b/Signal/test/Models/AccountManagerTest.swift
@@ -3,7 +3,6 @@
//
import XCTest
-import PromiseKit
import SignalServiceKit
@testable import Signal
diff --git a/Signal/test/Payments/PaymentsReconciliationTest.swift b/Signal/test/Payments/PaymentsReconciliationTest.swift
index e125d86351..d4d6292fda 100644
--- a/Signal/test/Payments/PaymentsReconciliationTest.swift
+++ b/Signal/test/Payments/PaymentsReconciliationTest.swift
@@ -3,7 +3,6 @@
//
import XCTest
-import PromiseKit
@testable import SignalServiceKit
@testable import SignalMessaging
@testable import Signal
diff --git a/Signal/test/Payments/PaymentsTest.swift b/Signal/test/Payments/PaymentsTest.swift
index 01ad2f0c7b..b484b11883 100644
--- a/Signal/test/Payments/PaymentsTest.swift
+++ b/Signal/test/Payments/PaymentsTest.swift
@@ -3,7 +3,6 @@
//
import XCTest
-import PromiseKit
@testable import SignalServiceKit
@testable import SignalMessaging
@testable import Signal
diff --git a/Signal/test/PerformanceTests/MessageSendingPerformanceTest.swift b/Signal/test/PerformanceTests/MessageSendingPerformanceTest.swift
index 7a8ddd552a..142f0d056f 100644
--- a/Signal/test/PerformanceTests/MessageSendingPerformanceTest.swift
+++ b/Signal/test/PerformanceTests/MessageSendingPerformanceTest.swift
@@ -3,7 +3,6 @@
//
import XCTest
-import PromiseKit
@testable import SignalServiceKit
import GRDB
@@ -225,13 +224,13 @@ class StubbableNetworkManager: NetworkManager {
// async's a little more realistic.
let fakeNetworkLatency = DispatchTimeInterval.milliseconds(25)
let block = self.block
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
DispatchQueue.global().asyncAfter(deadline: .now() + fakeNetworkLatency) {
let success = { response in
- resolver.fulfill(response)
+ future.resolve(response)
}
let failure = { error in
- resolver.reject(error)
+ future.reject(error)
}
block(request, success, failure)
}
diff --git a/SignalMessaging/Notifications/AppNotifications.swift b/SignalMessaging/Notifications/AppNotifications.swift
index 6eef83c2ad..c7e738193b 100644
--- a/SignalMessaging/Notifications/AppNotifications.swift
+++ b/SignalMessaging/Notifications/AppNotifications.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import Intents
/// There are two primary components in our system notification integration:
diff --git a/SignalMessaging/Notifications/UserNotificationsAdaptee.swift b/SignalMessaging/Notifications/UserNotificationsAdaptee.swift
index e44f5b63a7..5f4a9d96d1 100644
--- a/SignalMessaging/Notifications/UserNotificationsAdaptee.swift
+++ b/SignalMessaging/Notifications/UserNotificationsAdaptee.swift
@@ -4,7 +4,6 @@
import Foundation
import UserNotifications
-import PromiseKit
import Intents
public class UserNotificationConfig {
@@ -148,7 +147,7 @@ class UserNotificationPresenterAdaptee: NSObject, NotificationPresenterAdaptee {
}
func registerNotificationSettings() -> Promise {
- return Promise { resolver in
+ return Promise { future in
notificationCenter.requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
self.notificationCenter.setNotificationCategories(UserNotificationConfig.allNotificationCategories)
@@ -163,7 +162,7 @@ class UserNotificationPresenterAdaptee: NSObject, NotificationPresenterAdaptee {
// Note that the promise is fulfilled regardless of if notification permssions were
// granted. This promise only indicates that the user has responded, so we can
// proceed with requesting push tokens and complete registration.
- resolver.fulfill(())
+ future.resolve()
}
}
}
@@ -458,14 +457,14 @@ class UserNotificationPresenterAdaptee: NSObject, NotificationPresenterAdaptee {
}
func getDeliveredNotifications() -> Guarantee<[UNNotification]> {
- return Guarantee { resolver in
- self.notificationCenter.getDeliveredNotifications { resolver($0) }
+ return Guarantee { resolve in
+ self.notificationCenter.getDeliveredNotifications { resolve($0) }
}
}
func getPendingNotificationRequests() -> Guarantee<[UNNotificationRequest]> {
- return Guarantee { resolver in
- self.notificationCenter.getPendingNotificationRequests { resolver($0) }
+ return Guarantee { resolve in
+ self.notificationCenter.getPendingNotificationRequests { resolve($0) }
}
}
}
diff --git a/SignalMessaging/Payments/MobileCoinAPI.swift b/SignalMessaging/Payments/MobileCoinAPI.swift
index e3c15d52ca..6db70d2b69 100644
--- a/SignalMessaging/Payments/MobileCoinAPI.swift
+++ b/SignalMessaging/Payments/MobileCoinAPI.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import MobileCoin
public class MobileCoinAPI: Dependencies {
@@ -134,7 +133,7 @@ public class MobileCoinAPI: Dependencies {
let client = self.client
return firstly(on: .global()) { () throws -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -142,10 +141,10 @@ public class MobileCoinAPI: Dependencies {
client.updateBalance { (result: Swift.Result) in
switch result {
case .success(let balance):
- resolver.fulfill(balance)
+ future.resolve(balance)
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
@@ -175,7 +174,7 @@ public class MobileCoinAPI: Dependencies {
// We don't need to support amountPicoMobHigh.
return firstly(on: .global()) { () -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -187,14 +186,14 @@ public class MobileCoinAPI: Dependencies {
case .success(let feePicoMob):
let fee = TSPaymentAmount(currency: .mobileCoin, picoMob: feePicoMob)
guard fee.isValidAmount(canBeEmpty: false) else {
- resolver.reject(OWSAssertionError("Invalid amount."))
+ future.reject(OWSAssertionError("Invalid amount."))
return
}
Logger.verbose("Success paymentAmount: \(paymentAmount), fee: \(fee), ")
- resolver.fulfill(fee)
+ future.resolve(fee)
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
@@ -216,7 +215,7 @@ public class MobileCoinAPI: Dependencies {
let client = self.client
return firstly(on: .global()) { () -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -227,14 +226,14 @@ public class MobileCoinAPI: Dependencies {
case .success(let feePicoMob):
let paymentAmount = TSPaymentAmount(currency: .mobileCoin, picoMob: feePicoMob)
guard paymentAmount.isValidAmount(canBeEmpty: true) else {
- resolver.reject(OWSAssertionError("Invalid amount."))
+ future.reject(OWSAssertionError("Invalid amount."))
return
}
Logger.verbose("Success paymentAmount: \(paymentAmount), ")
- resolver.fulfill(paymentAmount)
+ future.resolve(paymentAmount)
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
@@ -286,7 +285,7 @@ public class MobileCoinAPI: Dependencies {
throw OWSAssertionError("Invalid fee.")
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -306,10 +305,10 @@ public class MobileCoinAPI: Dependencies {
let preparedTransaction = PreparedTransaction(transaction: transaction,
receipt: receipt,
feeAmount: finalFeeAmount)
- resolver.fulfill(preparedTransaction)
+ future.resolve(preparedTransaction)
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
@@ -330,7 +329,7 @@ public class MobileCoinAPI: Dependencies {
let client = self.client
return firstly(on: .global()) { () -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -340,10 +339,10 @@ public class MobileCoinAPI: Dependencies {
TransactionEstimationFetcherError>) in
switch result {
case .success(let shouldDefragment):
- resolver.fulfill(shouldDefragment)
+ future.resolve(shouldDefragment)
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
@@ -361,7 +360,7 @@ public class MobileCoinAPI: Dependencies {
let client = self.client
return firstly(on: .global()) { () throws -> Promise<[MobileCoin.Transaction]> in
- let (promise, resolver) = Promise<[MobileCoin.Transaction]>.pending()
+ let (promise, future) = Promise<[MobileCoin.Transaction]>.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -371,11 +370,11 @@ public class MobileCoinAPI: Dependencies {
MobileCoin.DefragTransactionPreparationError>) in
switch result {
case .success(let transactions):
- resolver.fulfill(transactions)
+ future.resolve(transactions)
break
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
break
}
}
@@ -393,7 +392,7 @@ public class MobileCoinAPI: Dependencies {
}
return firstly(on: .global()) { () throws -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -402,11 +401,11 @@ public class MobileCoinAPI: Dependencies {
client.submitTransaction(transaction) { (result: Swift.Result) in
switch result {
case .success:
- resolver.fulfill(())
+ future.resolve()
break
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
break
}
}
@@ -435,7 +434,7 @@ public class MobileCoinAPI: Dependencies {
// TODO: We could improve perf when verifying multiple transactions by getting balance just once.
self.getLocalBalance()
}.then(on: .global()) { (_: TSPaymentAmount) -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -443,11 +442,11 @@ public class MobileCoinAPI: Dependencies {
client.status(of: transaction) { (result: Swift.Result) in
switch result {
case .success(let transactionStatus):
- resolver.fulfill(MCOutgoingTransactionStatus(transactionStatus: transactionStatus))
+ future.resolve(MCOutgoingTransactionStatus(transactionStatus: transactionStatus))
break
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
break
}
}
@@ -536,7 +535,7 @@ public class MobileCoinAPI: Dependencies {
let client = self.client
return firstly(on: .global()) { () throws -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
if DebugFlags.paymentsNoRequestsComplete.get() {
// Never resolve.
return promise
@@ -544,10 +543,10 @@ public class MobileCoinAPI: Dependencies {
client.updateBalance { (result: Swift.Result) in
switch result {
case .success:
- resolver.fulfill(client.accountActivity)
+ future.resolve(client.accountActivity)
case .failure(let error):
let error = Self.convertMCError(error: error)
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
diff --git a/SignalMessaging/Payments/PaymentsCurrenciesImpl.swift b/SignalMessaging/Payments/PaymentsCurrenciesImpl.swift
index 4dfc29a30a..3f98017fe7 100644
--- a/SignalMessaging/Payments/PaymentsCurrenciesImpl.swift
+++ b/SignalMessaging/Payments/PaymentsCurrenciesImpl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class PaymentsCurrenciesImpl: NSObject, PaymentsCurrenciesSwift {
diff --git a/SignalMessaging/Payments/PaymentsImpl.swift b/SignalMessaging/Payments/PaymentsImpl.swift
index d717f9d496..25f95ca7cb 100644
--- a/SignalMessaging/Payments/PaymentsImpl.swift
+++ b/SignalMessaging/Payments/PaymentsImpl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import MobileCoin
@objc
@@ -944,7 +943,7 @@ public extension PaymentsImpl {
}
}
}
- return when(fulfilled: promises)
+ return Promise.when(fulfilled: promises)
}.timeout(seconds: maxBlockInterval, description: "blockOnVerificationOfDefragmentation") { () -> Error in
PaymentsError.timeout
}
@@ -965,7 +964,7 @@ public extension PaymentsImpl {
.outgoingUnverified:
// Not yet verified, wait then try again.
return firstly(on: .global()) {
- after(seconds: 0.05)
+ Guarantee.after(seconds: 0.05)
}.then(on: .global()) { () -> Promise in
// Recurse.
self.blockOnOutgoingVerification(paymentModel: paymentModel)
diff --git a/SignalMessaging/Payments/PaymentsProcessor.swift b/SignalMessaging/Payments/PaymentsProcessor.swift
index 12dc3ce2f4..9b5b30d71d 100644
--- a/SignalMessaging/Payments/PaymentsProcessor.swift
+++ b/SignalMessaging/Payments/PaymentsProcessor.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import MobileCoin
@objc
diff --git a/SignalMessaging/Payments/PaymentsReconciliation.swift b/SignalMessaging/Payments/PaymentsReconciliation.swift
index cd7348eca1..1c2c683227 100644
--- a/SignalMessaging/Payments/PaymentsReconciliation.swift
+++ b/SignalMessaging/Payments/PaymentsReconciliation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import MobileCoin
public class PaymentsReconciliation: Dependencies {
diff --git a/SignalMessaging/Payments/PaymentsUI.swift b/SignalMessaging/Payments/PaymentsUI.swift
index d0f2769e16..2f0a16e725 100644
--- a/SignalMessaging/Payments/PaymentsUI.swift
+++ b/SignalMessaging/Payments/PaymentsUI.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class PaymentsUI: NSObject {
@@ -56,7 +55,7 @@ public extension PaymentsUI {
canCancel: false) { modalActivityIndicator in
firstly(on: .global()) {
declinePaymentRequestPromise(paymentRequestModel: paymentRequestModel)
- }.done { _ in
+ }.done(on: .main) { _ in
modalActivityIndicator.dismiss {}
}.catch { error in
owsFailDebug("Error: \(error)")
@@ -105,7 +104,7 @@ public extension PaymentsUI {
canCancel: false) { modalActivityIndicator in
firstly(on: .global()) {
cancelPaymentRequestPromise(paymentRequestModel: paymentRequestModel)
- }.done { _ in
+ }.done(on: .main) { _ in
modalActivityIndicator.dismiss {}
}.catch { error in
owsFailDebug("Error: \(error)")
diff --git a/SignalMessaging/Storage Service/StorageServiceManager.swift b/SignalMessaging/Storage Service/StorageServiceManager.swift
index 7121cd29b1..f3a31a13db 100644
--- a/SignalMessaging/Storage Service/StorageServiceManager.swift
+++ b/SignalMessaging/Storage Service/StorageServiceManager.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc(OWSStorageServiceManager)
public class StorageServiceManager: NSObject, StorageServiceManagerProtocol {
@@ -244,11 +243,11 @@ class StorageServiceOperation: OWSOperation {
private let mode: Mode
let promise: Promise
- private let resolver: Resolver
+ private let future: Future
fileprivate init(mode: Mode) {
self.mode = mode
- (self.promise, self.resolver) = Promise.pending()
+ (self.promise, self.future) = Promise.pending()
super.init()
self.remainingRetries = 4
}
@@ -257,12 +256,12 @@ class StorageServiceOperation: OWSOperation {
override func didSucceed() {
super.didSucceed()
- resolver.fulfill(())
+ future.resolve()
}
override func didFail(error: Error) {
super.didFail(error: error)
- resolver.reject(error)
+ future.reject(error)
}
// Called every retry, this is where the bulk of the operation's work should go.
diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift
index cea11a0082..dd9725605f 100644
--- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift
+++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift
@@ -6,7 +6,6 @@ import Foundation
import AVFoundation
import MediaPlayer
import Photos
-import PromiseKit
@objc
public protocol AttachmentApprovalViewControllerDelegate: AnyObject {
@@ -654,7 +653,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
attachment.preparedForOutput(qualityLevel: outputQualityLevel)
})
}
- return when(fulfilled: promises)
+ return Promise.when(fulfilled: promises)
}
// For any attachments edited with an editor, returns a
@@ -885,7 +884,7 @@ extension AttachmentApprovalViewController: AttachmentTextToolbarDelegate {
// make below are reflected afterwards.
ModalActivityIndicatorViewController.present(fromViewController: self, canCancel: false) { modalVC in
self.outputAttachmentsPromise()
- .done { attachments in
+ .done(on: .main) { attachments in
AssertIsOnMainThread()
modalVC.dismiss {
AssertIsOnMainThread()
diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentItemCollection.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentItemCollection.swift
index 8b7946ac97..458b1f8cfc 100644
--- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentItemCollection.swift
+++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentItemCollection.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
class AddMoreRailItem: GalleryRailItem {
func buildRailItemView() -> UIView {
diff --git a/SignalMessaging/ViewControllers/ConversationPicker/ConversationPicker.swift b/SignalMessaging/ViewControllers/ConversationPicker/ConversationPicker.swift
index b0b783ebbe..91a07c268f 100644
--- a/SignalMessaging/ViewControllers/ConversationPicker/ConversationPicker.swift
+++ b/SignalMessaging/ViewControllers/ConversationPicker/ConversationPicker.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
public protocol ConversationPickerDelegate: AnyObject {
func conversationPickerSelectionDidChange(_ conversationPickerViewController: ConversationPickerViewController)
@@ -536,10 +535,10 @@ extension ConversationPickerViewController: UISearchBarDelegate {
buildSearchResults(searchText: searchText)
}.then { [weak self] searchResults -> Promise in
guard let self = self else {
- throw PMKError.cancelled
+ throw PromiseError.cancelled
}
return self.buildConversationCollection(searchResults: searchResults)
- }.done { [weak self] conversationCollection in
+ }.done(on: .main) { [weak self] conversationCollection in
guard let self = self else { return }
self.conversationCollection = conversationCollection
diff --git a/SignalMessaging/ViewControllers/FindByPhoneNumberViewController.swift b/SignalMessaging/ViewControllers/FindByPhoneNumberViewController.swift
index 8861e20f8c..ece33d80f3 100644
--- a/SignalMessaging/ViewControllers/FindByPhoneNumberViewController.swift
+++ b/SignalMessaging/ViewControllers/FindByPhoneNumberViewController.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public protocol FindByPhoneNumberDelegate: AnyObject {
diff --git a/SignalMessaging/ViewControllers/ModalActivityIndicatorViewController.swift b/SignalMessaging/ViewControllers/ModalActivityIndicatorViewController.swift
index fa587c8750..2f2bc67d4a 100644
--- a/SignalMessaging/ViewControllers/ModalActivityIndicatorViewController.swift
+++ b/SignalMessaging/ViewControllers/ModalActivityIndicatorViewController.swift
@@ -5,7 +5,6 @@
import Foundation
import MediaPlayer
import SignalServiceKit
-import PromiseKit
// A modal view that be used during blocking interactions (e.g. waiting on response from
// service or on the completion of a long-running local operation).
@@ -22,7 +21,7 @@ public class ModalActivityIndicatorViewController: OWSViewController {
_wasCancelled.get()
}
public let wasCancelledPromise: Promise
- private let wasCancelledResolver: Resolver
+ private let wasCancelledFuture: Future
var activityIndicator: UIActivityIndicatorView?
@@ -40,9 +39,9 @@ public class ModalActivityIndicatorViewController: OWSViewController {
self.presentationDelay = presentationDelay
self.isInvisible = isInvisible
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.wasCancelledPromise = promise
- self.wasCancelledResolver = resolver
+ self.wasCancelledFuture = future
super.init()
}
@@ -107,7 +106,7 @@ public class ModalActivityIndicatorViewController: OWSViewController {
let completion = {
completionParam()
- self.wasCancelledResolver.reject(OWSGenericError("ModalActivityIndicatorViewController was not cancelled."))
+ self.wasCancelledFuture.reject(OWSGenericError("ModalActivityIndicatorViewController was not cancelled."))
}
if !wasDimissed {
@@ -220,7 +219,7 @@ public class ModalActivityIndicatorViewController: OWSViewController {
_wasCancelled.set(true)
- self.wasCancelledResolver.fulfill(())
+ self.wasCancelledFuture.resolve()
dismiss {}
}
diff --git a/SignalMessaging/ViewControllers/Stickers/StickerPackDataSource.swift b/SignalMessaging/ViewControllers/Stickers/StickerPackDataSource.swift
index 4796b7f1aa..3a8e1f6d1e 100644
--- a/SignalMessaging/ViewControllers/Stickers/StickerPackDataSource.swift
+++ b/SignalMessaging/ViewControllers/Stickers/StickerPackDataSource.swift
@@ -405,7 +405,7 @@ public class TransientStickerPackDataSource: BaseStickerPackDataSource {
downloadKeySet.insert(key)
StickerManager.tryToDownloadStickerPack(stickerPackInfo: stickerPackInfo)
- .done { [weak self] (stickerPack) in
+ .done(on: .main) { [weak self] (stickerPack) in
guard let self = self else {
return
}
@@ -458,7 +458,7 @@ public class TransientStickerPackDataSource: BaseStickerPackDataSource {
// This sticker is not downloaded; try to download now.
firstly(on: .global()) {
StickerManager.tryToDownloadSticker(stickerPack: stickerPack, stickerInfo: stickerInfo)
- }.done { [weak self] (temporaryFileUrl) in
+ }.done(on: .main) { [weak self] (temporaryFileUrl) in
guard let self = self else {
return
}
diff --git a/SignalMessaging/ViewControllers/TextApprovalViewController.swift b/SignalMessaging/ViewControllers/TextApprovalViewController.swift
index afb627bff6..79de36d657 100644
--- a/SignalMessaging/ViewControllers/TextApprovalViewController.swift
+++ b/SignalMessaging/ViewControllers/TextApprovalViewController.swift
@@ -128,7 +128,7 @@ public class TextApprovalViewController: OWSViewController, MentionTextViewDeleg
isDraft: true)
linkPreviewView.isHidden = false
- linkPreviewManager.fetchLinkPreview(for: previewUrl).done { [weak self] draft in
+ linkPreviewManager.fetchLinkPreview(for: previewUrl).done(on: .main) { [weak self] draft in
guard let self = self else { return }
guard self.currentPreviewUrl == previewUrl else { return }
linkPreviewView.configureForNonCVC(state: LinkPreviewDraft(linkPreviewDraft: draft),
diff --git a/SignalMessaging/Views/GalleryRailView.swift b/SignalMessaging/Views/GalleryRailView.swift
index 906cc0140f..58250fe019 100644
--- a/SignalMessaging/Views/GalleryRailView.swift
+++ b/SignalMessaging/Views/GalleryRailView.swift
@@ -1,9 +1,7 @@
//
-// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
+// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
-import PromiseKit
-
public protocol GalleryRailItemProvider: AnyObject {
var railItems: [GalleryRailItem] { get }
}
diff --git a/SignalMessaging/Views/LoopingVideoView.swift b/SignalMessaging/Views/LoopingVideoView.swift
index 0e7f794821..1195bd284c 100644
--- a/SignalMessaging/Views/LoopingVideoView.swift
+++ b/SignalMessaging/Views/LoopingVideoView.swift
@@ -4,7 +4,6 @@
import YYImage
import AVKit
-import PromiseKit
/// Model object for a looping video asset
/// Any LoopingVideoViews playing this instance will all be kept in sync
@@ -193,8 +192,8 @@ public class LoopingVideoView: UIView {
guard let asset = video?.asset else {
// If we have an outstanding promise, invalidate the size once it's complete
// If there isn't, -noIntrinsicMetric is valid
- if video?.assetPromise.isPending == true {
- video?.assetPromise.done { _ in self.invalidateIntrinsicContentSize() }
+ if video?.assetPromise.isSealed != true {
+ video?.assetPromise.done(on: .main) { _ in self.invalidateIntrinsicContentSize() }
}
return CGSize(square: UIView.noIntrinsicMetric)
}
diff --git a/SignalMessaging/Views/VideoEditor/VideoEditorModel.swift b/SignalMessaging/Views/VideoEditor/VideoEditorModel.swift
index 8796597190..f6737b4b9f 100644
--- a/SignalMessaging/Views/VideoEditor/VideoEditorModel.swift
+++ b/SignalMessaging/Views/VideoEditor/VideoEditorModel.swift
@@ -4,7 +4,6 @@
import UIKit
import AVFoundation
-import PromiseKit
public enum VideoEditorError: Error {
case cancelled
@@ -347,20 +346,20 @@ extension VideoEditorModel {
fileprivate extension AVAssetExportSession {
func exportPromise() -> Promise {
- Promise { resolver in
+ Promise { future in
guard self.status != .cancelled else {
- resolver.reject(VideoEditorError.cancelled)
+ future.reject(VideoEditorError.cancelled)
return
}
exportAsynchronously {
switch (self.status, self.outputURL?.path) {
case (.completed, let path?):
- resolver.fulfill(path)
+ future.resolve(path)
case (.cancelled, _):
- resolver.reject(VideoEditorError.cancelled)
+ future.reject(VideoEditorError.cancelled)
default:
- resolver.reject(self.error ?? OWSAssertionError("Status \(self.status)"))
+ future.reject(self.error ?? OWSAssertionError("Status \(self.status)"))
}
}
}
diff --git a/SignalMessaging/Views/VideoEditor/VideoEditorView.swift b/SignalMessaging/Views/VideoEditor/VideoEditorView.swift
index a8861b4e85..baf39d108f 100644
--- a/SignalMessaging/Views/VideoEditor/VideoEditorView.swift
+++ b/SignalMessaging/Views/VideoEditor/VideoEditorView.swift
@@ -4,7 +4,6 @@
import UIKit
import AVFoundation
-import PromiseKit
import Photos
@objc
@@ -139,7 +138,7 @@ public class VideoEditorView: UIView {
displaySize: displaySize,
timelineHeight: timelineHeight,
untrimmedDurationSeconds: untrimmedDurationSeconds)
- }.done { [weak self] (thumbnails: [UIImage]) -> Void in
+ }.done(on: .main) { [weak self] (thumbnails: [UIImage]) -> Void in
guard let self = self else {
return
}
@@ -318,7 +317,7 @@ public class VideoEditorView: UIView {
ModalActivityIndicatorViewController.present(fromViewController: viewController, canCancel: false) { modalVC in
firstly {
self.saveVideoPromise()
- }.done {
+ }.done(on: .main) {
modalVC.dismiss {}
}.catch { _ in
modalVC.dismiss {
@@ -354,7 +353,7 @@ public class VideoEditorView: UIView {
}
}.then(on: .sharedUtility) { (videoFilePath: String) -> Promise in
- Promise { resolver in
+ Promise { future in
let videoUrl = URL(fileURLWithPath: videoFilePath)
PHPhotoLibrary.shared().performChanges {
@@ -363,14 +362,14 @@ public class VideoEditorView: UIView {
OWSFileSystem.deleteFileIfExists(videoFilePath)
if let error = error {
- resolver.reject(error)
+ future.reject(error)
return
}
guard didSucceed else {
- resolver.reject(OWSAssertionError("Video export failed."))
+ future.reject(OWSAssertionError("Video export failed."))
return
}
- resolver.fulfill(())
+ future.resolve()
}
}
}
@@ -513,7 +512,7 @@ class TrimVideoTimelineView: UIView {
addSubview(thumbnailLayerView)
thumbnailLayerView.clipsToBounds = true
thumbnailLayerView.autoPinEdgesToSuperviewEdges()
- thumbnailLayerView.layoutCallback = { [weak self] view in
+ thumbnailLayerView.layoutCallback = { [weak self] _ in
self?.updateThumbnailView()
}
diff --git a/SignalMessaging/attachments/AttachmentMultisend.swift b/SignalMessaging/attachments/AttachmentMultisend.swift
index 1a251ffc0e..7e8492d883 100644
--- a/SignalMessaging/attachments/AttachmentMultisend.swift
+++ b/SignalMessaging/attachments/AttachmentMultisend.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
public class AttachmentMultisend: Dependencies {
@@ -158,7 +157,7 @@ public class AttachmentMultisend: Dependencies {
}
}
- return when(fulfilled: messageSendPromises).map { threads }
+ return Promise.when(fulfilled: messageSendPromises).map { threads }
}
}
}
diff --git a/SignalMessaging/attachments/BroadcastMediaMessageJob.swift b/SignalMessaging/attachments/BroadcastMediaMessageJob.swift
index 20d0a02484..d0cb98a199 100644
--- a/SignalMessaging/attachments/BroadcastMediaMessageJob.swift
+++ b/SignalMessaging/attachments/BroadcastMediaMessageJob.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class BroadcastMediaMessageJobQueue: NSObject, JobQueue {
diff --git a/SignalMessaging/attachments/SignalAttachment.swift b/SignalMessaging/attachments/SignalAttachment.swift
index 6250774b2b..b682f9d41d 100644
--- a/SignalMessaging/attachments/SignalAttachment.swift
+++ b/SignalMessaging/attachments/SignalAttachment.swift
@@ -5,7 +5,6 @@
import Foundation
import MobileCoreServices
import SignalServiceKit
-import PromiseKit
import AVFoundation
import YYImage
@@ -1160,36 +1159,36 @@ public class SignalAttachment: NSObject {
let exportURL = videoTempPath.appendingPathComponent(UUID().uuidString).appendingPathExtension("mp4")
exportSession.outputURL = exportURL
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
Logger.debug("Starting video export")
exportSession.exportAsynchronously {
if let error = exportSession.error {
owsFailDebug("Error: \(error)")
- resolver.reject(error)
+ future.reject(error)
return
}
switch exportSession.status {
case .unknown:
- resolver.reject(OWSAssertionError("Unknown export status."))
+ future.reject(OWSAssertionError("Unknown export status."))
return
case .waiting:
- resolver.reject(OWSAssertionError("Export status: .waiting."))
+ future.reject(OWSAssertionError("Export status: .waiting."))
return
case .exporting:
- resolver.reject(OWSAssertionError("Export status: .exporting."))
+ future.reject(OWSAssertionError("Export status: .exporting."))
return
case .completed:
break
case .failed:
- resolver.reject(OWSAssertionError("Export failed without error."))
+ future.reject(OWSAssertionError("Export failed without error."))
return
case .cancelled:
- resolver.reject(OWSGenericError("Cancelled."))
+ future.reject(OWSGenericError("Cancelled."))
return
@unknown default:
- resolver.reject(OWSAssertionError("Unknown export status: \(exportSession.status.rawValue)"))
+ future.reject(OWSAssertionError("Unknown export status: \(exportSession.status.rawValue)"))
return
}
Logger.debug("Completed video export")
@@ -1201,12 +1200,12 @@ public class SignalAttachment: NSObject {
dataSource.sourceFilename = mp4Filename
let attachment = SignalAttachment(dataSource: dataSource, dataUTI: kUTTypeMPEG4 as String)
- resolver.fulfill(attachment)
+ future.resolve(attachment)
} catch {
owsFailDebug("Failed to build data source for exported video URL")
let attachment = SignalAttachment(dataSource: DataSourceValue.emptyDataSource(), dataUTI: dataUTI)
attachment.error = .couldNotConvertToMpeg4
- resolver.fulfill(attachment)
+ future.resolve(attachment)
return
}
}
diff --git a/SignalMessaging/contacts/IncomingContactSyncJobQueue.swift b/SignalMessaging/contacts/IncomingContactSyncJobQueue.swift
index 55831fe21e..1389a891bf 100644
--- a/SignalMessaging/contacts/IncomingContactSyncJobQueue.swift
+++ b/SignalMessaging/contacts/IncomingContactSyncJobQueue.swift
@@ -9,7 +9,6 @@ import Foundation
//
import Foundation
-import PromiseKit
public extension Notification.Name {
static let IncomingContactSyncDidComplete = Notification.Name("IncomingContactSyncDidComplete")
diff --git a/SignalMessaging/contacts/OWSContactsManager.m b/SignalMessaging/contacts/OWSContactsManager.m
index 661d8b8224..ebb6e80f3d 100644
--- a/SignalMessaging/contacts/OWSContactsManager.m
+++ b/SignalMessaging/contacts/OWSContactsManager.m
@@ -7,9 +7,9 @@
#import "OWSProfileManager.h"
#import "ViewControllerUtils.h"
#import
-#import
#import
#import
+#import
#import
#import
#import
@@ -112,14 +112,16 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (AnyPromise *)userRequestedSystemContactsRefresh
{
- return [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
- [self.systemContactsFetcher userRequestedRefreshWithCompletion:^(NSError *error){
+ return AnyPromise.withFuture(^(AnyFuture *future) {
+ [self.systemContactsFetcher userRequestedRefreshWithCompletion:^(NSError *error) {
if (error) {
OWSLogError(@"refreshing contacts failed with error: %@", error);
+ [future rejectWithError:error];
+ } else {
+ [future resolveWithValue:@1];
}
- resolve(error ?: @(1));
}];
- }];
+ });
}
- (BOOL)isSystemContactsAuthorized
diff --git a/SignalMessaging/contacts/OWSGroupSyncProcessingJobQueue.swift b/SignalMessaging/contacts/OWSGroupSyncProcessingJobQueue.swift
index bf6a7ca00c..83ab0dab45 100644
--- a/SignalMessaging/contacts/OWSGroupSyncProcessingJobQueue.swift
+++ b/SignalMessaging/contacts/OWSGroupSyncProcessingJobQueue.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
public extension Notification.Name {
diff --git a/SignalMessaging/contacts/OWSSyncManager.m b/SignalMessaging/contacts/OWSSyncManager.m
index 7e506dddfe..0622dd3d31 100644
--- a/SignalMessaging/contacts/OWSSyncManager.m
+++ b/SignalMessaging/contacts/OWSSyncManager.m
@@ -9,7 +9,6 @@
#import "OWSProfileManager.h"
#import "OWSReceiptManager.h"
#import
-#import
#import
#import
#import
@@ -342,23 +341,23 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
OWSAssertDebug(!isDurableSend);
}
- AnyPromise *promise = [AnyPromise promiseWithResolverBlock:^(PMKResolver resolve) {
+ AnyPromise *promise = AnyPromise.withFuture(^(AnyFuture *future) {
AppReadinessRunNowOrWhenAppDidBecomeReadyAsync(^{
dispatch_async(self.serialQueue, ^{
if (debounce && self.isRequestInFlight) {
// De-bounce. It's okay if we ignore some new changes;
// `sendSyncContactsMessageIfPossible` is called fairly
// often so we'll sync soon.
- return resolve(@(1));
+ return [future resolveWithValue:@(1)];
}
-
+
TSThread *_Nullable thread = [TSAccountManager getOrCreateLocalThreadWithSneakyTransaction];
if (thread == nil) {
OWSFailDebug(@"Missing thread.");
NSError *error = [OWSError withError:OWSErrorCodeContactSyncFailed
description:@"Could not sync contacts."
isRetryable:NO];
- return resolve(error);
+ return [future rejectWithError:error];
}
OWSSyncContactsMessage *syncContactsMessage =
@@ -376,16 +375,16 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
NSError *error = [OWSError withError:OWSErrorCodeContactSyncFailed
description:@"Could not sync contacts."
isRetryable:NO];
- return resolve(error);
+ return [future rejectWithError:error];
}
-
+
NSData *_Nullable messageHash = [self hashForMessageData:messageData];
if (skipIfRedundant && messageHash != nil && lastMessageHash != nil &&
[lastMessageHash isEqual:messageHash]) {
// Ignore redundant contacts sync message.
- return resolve(@(1));
+ return [future resolveWithValue:@(1)];
}
-
+
if (debounce) {
self.isRequestInFlight = YES;
}
@@ -399,7 +398,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
if (debounce) {
self.isRequestInFlight = NO;
}
- resolve(writeError);
+ [future rejectWithError:writeError];
return;
}
@@ -414,7 +413,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
if (debounce) {
self.isRequestInFlight = NO;
}
- return resolve(@(1));
+ return [future resolveWithValue:@(1)];
} else {
[self.messageSender sendTemporaryAttachment:dataSource
contentType:OWSMimeTypeApplicationOctetStream
@@ -435,7 +434,7 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
self.isRequestInFlight = NO;
}
- resolve(@(1));
+ [future resolveWithValue:@(1)];
});
}
failure:^(NSError *error) {
@@ -446,13 +445,13 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
self.isRequestInFlight = NO;
}
- resolve(error);
+ [future rejectWithError:error];
});
}];
}
});
});
- }];
+ });
return promise;
}
diff --git a/SignalMessaging/contacts/OWSSyncManager.swift b/SignalMessaging/contacts/OWSSyncManager.swift
index 6d97eb298a..0dd314530a 100644
--- a/SignalMessaging/contacts/OWSSyncManager.swift
+++ b/SignalMessaging/contacts/OWSSyncManager.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
extension OWSSyncManager: SyncManagerProtocolSwift {
@@ -35,7 +34,7 @@ extension OWSSyncManager: SyncManagerProtocolSwift {
self.sendSyncRequestMessage(.keys, transaction: transaction)
}
- return when(fulfilled: [
+ return Promise.when(fulfilled: [
NotificationCenter.default.observe(once: .IncomingContactSyncDidComplete).asVoid(),
NotificationCenter.default.observe(once: .IncomingGroupSyncDidComplete).asVoid(),
NotificationCenter.default.observe(once: .OWSSyncManagerConfigurationSyncDidComplete).asVoid(),
@@ -173,7 +172,7 @@ public extension OWSSyncManager {
self.sendSyncRequestMessage(.contacts, transaction: transaction)
}
- let notificationsPromise: Promise<([(threadId: String, sortOrder: UInt32)], [(threadId: String, sortOrder: UInt32)], Void, Void)> = when(fulfilled:
+ let notificationsPromise: Promise<([(threadId: String, sortOrder: UInt32)], [(threadId: String, sortOrder: UInt32)], Void, Void)> = Promise.when(fulfilled:
NotificationCenter.default.observe(once: .IncomingContactSyncDidComplete).map { $0.newThreads }.timeout(seconds: timeoutSeconds, substituteValue: []),
NotificationCenter.default.observe(once: .IncomingGroupSyncDidComplete).map { $0.newThreads }.timeout(seconds: timeoutSeconds, substituteValue: []),
NotificationCenter.default.observe(once: .OWSSyncManagerConfigurationSyncDidComplete).asVoid().timeout(seconds: timeoutSeconds),
diff --git a/SignalMessaging/groups/GroupV2SnapshotImpl.swift b/SignalMessaging/groups/GroupV2SnapshotImpl.swift
index 2ca95adb23..d119265724 100644
--- a/SignalMessaging/groups/GroupV2SnapshotImpl.swift
+++ b/SignalMessaging/groups/GroupV2SnapshotImpl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import ZKGroup
diff --git a/SignalMessaging/groups/GroupV2UpdatesImpl.swift b/SignalMessaging/groups/GroupV2UpdatesImpl.swift
index 9fa15ef4a4..44b62d40b8 100644
--- a/SignalMessaging/groups/GroupV2UpdatesImpl.swift
+++ b/SignalMessaging/groups/GroupV2UpdatesImpl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import ZKGroup
@@ -280,7 +279,7 @@ public class GroupV2UpdatesImpl: NSObject, GroupV2UpdatesSwift {
let groupModelOptions: TSGroupModelOptions
let promise: Promise
- let resolver: Resolver
+ let future: Future
// MARK: -
@@ -293,9 +292,9 @@ public class GroupV2UpdatesImpl: NSObject, GroupV2UpdatesSwift {
self.groupUpdateMode = groupUpdateMode
self.groupModelOptions = groupModelOptions
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.promise = promise
- self.resolver = resolver
+ self.future = future
super.init()
@@ -319,7 +318,7 @@ public class GroupV2UpdatesImpl: NSObject, GroupV2UpdatesSwift {
Logger.verbose("Group refresh succeeded.")
self.reportSuccess()
- self.resolver.fulfill(groupThread)
+ self.future.resolve(groupThread)
}.catch(on: .global()) { (error) in
if IsNetworkConnectivityFailure(error) {
Logger.warn("Group update failed: \(error)")
@@ -364,7 +363,7 @@ public class GroupV2UpdatesImpl: NSObject, GroupV2UpdatesSwift {
public override func didFail(error: Error) {
Logger.error("failed with error: \(error)")
- resolver.reject(error)
+ future.reject(error)
}
}
diff --git a/SignalMessaging/groups/GroupsV2AvatarDownloadOperation.swift b/SignalMessaging/groups/GroupsV2AvatarDownloadOperation.swift
index 7434b27354..1f509f0056 100644
--- a/SignalMessaging/groups/GroupsV2AvatarDownloadOperation.swift
+++ b/SignalMessaging/groups/GroupsV2AvatarDownloadOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
class GroupsV2AvatarDownloadOperation: CDNDownloadOperation {
@@ -11,16 +10,16 @@ class GroupsV2AvatarDownloadOperation: CDNDownloadOperation {
private let urlPath: String
private let maxDownloadSize: UInt?
public let promise: Promise
- private let resolver: Resolver
+ private let future: Future
public required init(urlPath: String,
maxDownloadSize: UInt? = nil) {
self.urlPath = urlPath
self.maxDownloadSize = maxDownloadSize
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.promise = promise
- self.resolver = resolver
+ self.future = future
super.init()
}
@@ -33,7 +32,7 @@ class GroupsV2AvatarDownloadOperation: CDNDownloadOperation {
return
}
- self.resolver.fulfill(data)
+ self.future.resolve(data)
self.reportSuccess()
}.catch(on: DispatchQueue.global()) { [weak self] error in
guard let self = self else {
@@ -46,6 +45,6 @@ class GroupsV2AvatarDownloadOperation: CDNDownloadOperation {
override public func didFail(error: Error) {
Logger.error("Download exhausted retries: \(error)")
- resolver.reject(error)
+ future.reject(error)
}
}
diff --git a/SignalMessaging/groups/GroupsV2Impl+RestoreGroups.swift b/SignalMessaging/groups/GroupsV2Impl+RestoreGroups.swift
index 296247bede..7681b0c441 100644
--- a/SignalMessaging/groups/GroupsV2Impl+RestoreGroups.swift
+++ b/SignalMessaging/groups/GroupsV2Impl+RestoreGroups.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
public extension GroupsV2Impl {
@@ -135,12 +134,12 @@ public extension GroupsV2Impl {
guard canProcessGroupRestore else {
return Promise.value(.cantProcess)
}
- return Promise { resolver in
+ return Promise { future in
DispatchQueue.global().async {
guard let masterKeyData = (self.databaseStorage.read { transaction in
groupsFromStorageService_EnqueuedForRestore.anyDataValue(transaction: transaction)
}) else {
- return resolver.fulfill(.emptyQueue)
+ return future.resolve(.emptyQueue)
}
let key = self.restoreGroupKey(forMasterKeyData: masterKeyData)
@@ -165,7 +164,7 @@ public extension GroupsV2Impl {
} catch {
owsFailDebug("Error: \(error)")
markAsFailed()
- return resolver.fulfill(.unretryableFailure)
+ return future.resolve(.unretryableFailure)
}
let isGroupInDatabase = self.databaseStorage.read { transaction in
@@ -174,7 +173,7 @@ public extension GroupsV2Impl {
guard !isGroupInDatabase else {
// No work to be done, group already in database.
markAsComplete()
- return resolver.fulfill(.success)
+ return future.resolve(.success)
}
// This will try to update the group using incremental "changes" but
@@ -187,11 +186,11 @@ public extension GroupsV2Impl {
}.done { _ in
Logger.verbose("Update succeeded.")
markAsComplete()
- resolver.fulfill(.success)
+ future.resolve(.success)
}.catch { error in
if IsNetworkConnectivityFailure(error) {
Logger.warn("Error: \(error)")
- return resolver.fulfill(.retryableFailure)
+ return future.resolve(.retryableFailure)
} else {
switch error {
case GroupsV2Error.localUserNotInGroup:
@@ -200,7 +199,7 @@ public extension GroupsV2Impl {
owsFailDebug("Error: \(error)")
}
markAsFailed()
- return resolver.fulfill(.unretryableFailure)
+ return future.resolve(.unretryableFailure)
}
}
}
diff --git a/SignalMessaging/groups/GroupsV2Impl.swift b/SignalMessaging/groups/GroupsV2Impl.swift
index def1b96077..a9b9922c6e 100644
--- a/SignalMessaging/groups/GroupsV2Impl.swift
+++ b/SignalMessaging/groups/GroupsV2Impl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import SignalMetadataKit
import ZKGroup
@@ -722,22 +721,22 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
// avatar with the avatar data.
var promises = [Promise<(String, Data)>]()
for avatarUrlPath in undownloadedAvatarUrlPaths {
- let (downloadPromise, resolver) = Promise.pending()
+ let (downloadPromise, future) = Promise.pending()
firstly { () -> Promise in
self.fetchAvatarData(avatarUrlPath: avatarUrlPath,
groupV2Params: groupV2Params)
}.done(on: .global()) { avatarData in
- resolver.fulfill(avatarData)
+ future.resolve(avatarData)
}.catch(on: .global()) { error in
if let statusCode = error.httpStatusCode,
statusCode == 404 {
// Fulfill with empty data if service returns 404 status code.
// We don't want the group to be left in an unrecoverable state
// if the the avatar is missing from the CDN.
- resolver.fulfill(Data())
+ future.resolve(Data())
}
- resolver.reject(error)
+ future.reject(error)
}
let promise = downloadPromise.map(on: .global()) { (avatarData: Data) -> Data in
@@ -757,7 +756,7 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
}
promises.append(promise)
}
- return when(fulfilled: promises)
+ return Promise.when(fulfilled: promises)
}.map(on: .global()) { (avatars: [(String, Data)]) -> GroupV2DownloadedAvatars in
for (avatarUrlPath, avatarData) in avatars {
guard avatarData.count > 0 else {
@@ -858,11 +857,11 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
}.then(on: .global()) { (authCredential: AuthCredential) -> Promise in
try requestBuilder(authCredential)
}.then(on: .global()) { (request: GroupsV2Request) -> Promise in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
firstly {
self.performServiceRequestAttempt(request: request)
}.done(on: .global()) { (response: HTTPResponse) in
- resolver.fulfill(response)
+ future.resolve(response)
}.catch(on: .global()) { (error: Error) in
let retryIfPossible = {
@@ -874,12 +873,12 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
behavior404: behavior404,
remainingRetries: remainingRetries - 1)
}.done(on: .global()) { (response: HTTPResponse) in
- resolver.fulfill(response)
+ future.resolve(response)
}.catch(on: .global()) { (error: Error) in
- resolver.reject(error)
+ future.reject(error)
}
} else {
- resolver.reject(error)
+ future.reject(error)
}
}
@@ -929,38 +928,38 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
self.tryToUpdateGroupToLatest(groupId: groupId)
case .expiredGroupInviteLink:
owsFailDebug("groupId should not be set in this code path.")
- resolver.reject(GroupsV2Error.expiredGroupInviteLink)
+ future.reject(GroupsV2Error.expiredGroupInviteLink)
break
case .localUserIsNotARequestingMember:
owsFailDebug("groupId should not be set in this code path.")
- resolver.reject(GroupsV2Error.localUserIsNotARequestingMember)
+ future.reject(GroupsV2Error.localUserIsNotARequestingMember)
break
}
} else {
// We should only receive 403 when groupId is not nil.
if behavior403 == .expiredGroupInviteLink {
- resolver.reject(GroupsV2Error.expiredGroupInviteLink)
+ future.reject(GroupsV2Error.expiredGroupInviteLink)
return
} else if behavior403 == .localUserIsNotARequestingMember {
- resolver.reject(GroupsV2Error.localUserIsNotARequestingMember)
+ future.reject(GroupsV2Error.localUserIsNotARequestingMember)
return
} else {
owsFailDebug("Missing groupId.")
}
}
- resolver.reject(GroupsV2Error.localUserNotInGroup)
+ future.reject(GroupsV2Error.localUserNotInGroup)
case 404:
// 404 indicates that the group does not exist on the
// service for some (but not all) group v2 service requests.
switch behavior404 {
case .fail:
- resolver.reject(error)
+ future.reject(error)
break
case .groupDoesNotExistOnService:
Logger.warn("Error: \(error)")
- resolver.reject(GroupsV2Error.groupDoesNotExistOnService)
+ future.reject(GroupsV2Error.groupDoesNotExistOnService)
}
case 409:
// Group update conflict, retry. When updating group state,
@@ -968,14 +967,14 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
retryIfPossible()
default:
// Unexpected status code.
- resolver.reject(error)
+ future.reject(error)
}
} else if error.isNetworkFailureOrTimeout {
// Retry on network failure.
retryIfPossible()
} else {
// Unexpected error.
- resolver.reject(error)
+ future.reject(error)
}
}
return promise
@@ -1099,7 +1098,7 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
}
promises.append(promise)
}
- return when(fulfilled: promises)
+ return Promise.when(fulfilled: promises)
.map(on: .global()) { _ in
// Since we've just successfully fetched versioned profiles
// for all of the UUIDs without credentials, we _should_ be
@@ -1191,7 +1190,7 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
}
promises.append(promise)
}
- return when(fulfilled: promises)
+ return Promise.when(fulfilled: promises)
}
// MARK: - Auth Credentials
diff --git a/SignalMessaging/groups/GroupsV2Migration.swift b/SignalMessaging/groups/GroupsV2Migration.swift
index 58f95427a1..b04fa6e255 100644
--- a/SignalMessaging/groups/GroupsV2Migration.swift
+++ b/SignalMessaging/groups/GroupsV2Migration.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import ZKGroup
import SignalClient
@@ -465,7 +464,7 @@ fileprivate extension GroupsV2Migration {
switch profileFetchMode {
case .parallel:
let promises = addresses.map { fetchProfilePromise(address: $0) }
- return when(fulfilled: promises)
+ return Promise.when(fulfilled: promises)
case .serialWithThrottling:
guard let firstAddress = addresses.first else {
// No more profiles to fetch.
@@ -479,7 +478,7 @@ fileprivate extension GroupsV2Migration {
//
// The profile fetch rate limit is a bucket size of 4320, which
// refills at a rate of 3 per minute.
- after(seconds: 1.0 / 3.0)
+ Guarantee.after(seconds: 1.0 / 3.0)
}.then(on: .global()) {
// Recurse.
fetchProfiles(addresses: remainder, profileFetchMode: profileFetchMode)
@@ -1136,16 +1135,16 @@ private class MigrateGroupOperation: OWSOperation {
private let migrationMode: GroupsV2MigrationMode
fileprivate let promise: Promise
- fileprivate let resolver: Resolver
+ fileprivate let future: Future
fileprivate required init(groupId: Data,
migrationMode: GroupsV2MigrationMode) {
self.groupId = groupId
self.migrationMode = migrationMode
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.promise = promise
- self.resolver = resolver
+ self.future = future
super.init()
@@ -1167,13 +1166,13 @@ private class MigrateGroupOperation: OWSOperation {
Logger.info("success groupId: \(groupId.hexadecimalString), migrationMode: \(migrationMode)")
}
self.reportSuccess()
- self.resolver.fulfill(groupThread)
+ self.future.resolve(groupThread)
}.catch(on: .global()) { error in
if GroupsV2Migration.verboseLogging {
Logger.info("failure groupId: \(groupId.hexadecimalString), migrationMode: \(migrationMode), error: \(error)")
}
self.reportError(error)
- self.resolver.reject(error)
+ self.future.reject(error)
}
}
}
diff --git a/SignalMessaging/groups/GroupsV2OutgoingChangesImpl.swift b/SignalMessaging/groups/GroupsV2OutgoingChangesImpl.swift
index 442d4f08d9..fcae2cb5dd 100644
--- a/SignalMessaging/groups/GroupsV2OutgoingChangesImpl.swift
+++ b/SignalMessaging/groups/GroupsV2OutgoingChangesImpl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import ZKGroup
diff --git a/SignalMessaging/groups/GroupsV2ProfileKeyUpdater.swift b/SignalMessaging/groups/GroupsV2ProfileKeyUpdater.swift
index f2039e9071..17c3e38ada 100644
--- a/SignalMessaging/groups/GroupsV2ProfileKeyUpdater.swift
+++ b/SignalMessaging/groups/GroupsV2ProfileKeyUpdater.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
// Whenever we rotate our profile key, we need to update all
diff --git a/SignalMessaging/groups/GroupsV2Protos.swift b/SignalMessaging/groups/GroupsV2Protos.swift
index 8168915c49..a1b48575c4 100644
--- a/SignalMessaging/groups/GroupsV2Protos.swift
+++ b/SignalMessaging/groups/GroupsV2Protos.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import SignalMetadataKit
import ZKGroup
diff --git a/SignalMessaging/groups/GroupsV2Utils.swift b/SignalMessaging/groups/GroupsV2Utils.swift
index 15e7582d56..a6cd037315 100644
--- a/SignalMessaging/groups/GroupsV2Utils.swift
+++ b/SignalMessaging/groups/GroupsV2Utils.swift
@@ -1,9 +1,8 @@
//
-// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
+// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
import Foundation
-import PromiseKit
import SignalServiceKit
import SignalMetadataKit
import ZKGroup
diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m
index e04f38aaf0..78e81359a2 100644
--- a/SignalMessaging/profiles/OWSProfileManager.m
+++ b/SignalMessaging/profiles/OWSProfileManager.m
@@ -4,11 +4,11 @@
#import "OWSProfileManager.h"
#import "Environment.h"
-#import
#import
#import
#import
#import
+#import
#import
#import
#import
@@ -492,7 +492,7 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
- (void)reuploadLocalProfile
{
- [self reuploadLocalProfilePromise].then(^{ OWSLogInfo(@"Done."); }).catch(^(NSError *error) {
+ [self reuploadLocalProfilePromise].done(^(id value) { OWSLogInfo(@"Done."); }).catch(^(NSError *error) {
OWSFailDebugUnlessNetworkFailure(error);
});
}
@@ -616,7 +616,7 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
[self rotateProfileKeyWithIntersectingPhoneNumbers:intersectingPhoneNumbers
intersectingUUIDs:intersectingUUIDS
intersectingGroupIds:intersectingGroupIds]
- .then(^{ success(); })
+ .done(^(id value) { success(); })
.catch(^(NSError *error) { failure(error); });
});
}
@@ -1630,7 +1630,7 @@ const NSString *kNSNotificationKey_UserProfileWriter = @"kNSNotificationKey_User
[self downloadAndDecryptProfileAvatarForProfileAddress:userProfile.address
avatarUrlPath:avatarUrlPathAtStart
profileKey:profileKeyAtStart]
- .thenInBackground(^(id value) {
+ .doneInBackground(^(id value) {
if (![value isKindOfClass:[NSData class]]) {
OWSFailDebug(@"Invalid value.");
return;
diff --git a/SignalMessaging/profiles/OWSProfileManager.swift b/SignalMessaging/profiles/OWSProfileManager.swift
index a4545021c3..0223d0b6dd 100644
--- a/SignalMessaging/profiles/OWSProfileManager.swift
+++ b/SignalMessaging/profiles/OWSProfileManager.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
public extension OWSProfileManager {
@@ -34,7 +33,7 @@ public extension OWSProfileManager {
profileAvatarData: profileAvatarData,
unsavedRotatedProfileKey: unsavedRotatedProfileKey,
userProfileWriter: userProfileWriter)
- }.then { update in
+ }.then(on: .main) { update in
return self.attemptToUpdateProfileOnService(update: update)
}.then { (_) throws -> Promise in
guard unsavedRotatedProfileKey == nil else {
@@ -389,14 +388,14 @@ extension OWSProfileManager {
guard let profileAvatarData = attempt.update.profileAvatarData else {
return Promise.value(())
}
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
DispatchQueue.global().async {
self.profileManagerImpl.writeAvatarToDisk(with: profileAvatarData,
success: { avatarFilename in
attempt.avatarFilename = avatarFilename
- resolver.fulfill(())
+ future.resolve()
}, failure: { (error) in
- resolver.reject(error)
+ future.reject(error)
})
}
return promise
diff --git a/SignalMessaging/profiles/VersionedProfilesImpl.swift b/SignalMessaging/profiles/VersionedProfilesImpl.swift
index 0e87fbc50b..dae7efad2a 100644
--- a/SignalMessaging/profiles/VersionedProfilesImpl.swift
+++ b/SignalMessaging/profiles/VersionedProfilesImpl.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalServiceKit
import SignalMetadataKit
import ZKGroup
diff --git a/SignalMessaging/utils/BlockListUIUtils.m b/SignalMessaging/utils/BlockListUIUtils.m
index c837e0c52c..e73b3aac17 100644
--- a/SignalMessaging/utils/BlockListUIUtils.m
+++ b/SignalMessaging/utils/BlockListUIUtils.m
@@ -5,7 +5,6 @@
#import "BlockListUIUtils.h"
#import "OWSContactsManager.h"
#import "PhoneNumber.h"
-#import
#import
#import
#import
diff --git a/SignalMessaging/utils/GroupManager+SignalMessaging.swift b/SignalMessaging/utils/GroupManager+SignalMessaging.swift
index c61bd0c793..beaedf4ea3 100644
--- a/SignalMessaging/utils/GroupManager+SignalMessaging.swift
+++ b/SignalMessaging/utils/GroupManager+SignalMessaging.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public extension GroupManager {
@@ -19,10 +18,10 @@ public extension GroupManager {
}
ModalActivityIndicatorViewController.present(fromViewController: fromViewController, canCancel: false) { modalView in
- firstly {
+ firstly(on: .global()) {
self.leaveGroupOrDeclineInvitePromise(groupThread: groupThread,
replacementAdminUuid: replacementAdminUuid).asVoid()
- }.done { _ in
+ }.done(on: .main) { _ in
modalView.dismiss {
success?()
}
@@ -41,9 +40,9 @@ public extension GroupManager {
success: @escaping () -> Void) {
ModalActivityIndicatorViewController.present(fromViewController: fromViewController,
canCancel: false) { modalActivityIndicator in
- firstly { () -> Promise in
+ firstly(on: .global()) { () -> Promise in
self.acceptGroupInvitePromise(groupThread: groupThread)
- }.done { _ in
+ }.done(on: .main) { _ in
modalActivityIndicator.dismiss {
success()
}
diff --git a/SignalMessaging/utils/GroupViewUtils.swift b/SignalMessaging/utils/GroupViewUtils.swift
index c59d804176..15a7f40526 100644
--- a/SignalMessaging/utils/GroupViewUtils.swift
+++ b/SignalMessaging/utils/GroupViewUtils.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import UIKit
import SafariServices
@@ -31,7 +30,7 @@ public class GroupViewUtils {
canCancel: false) { modalActivityIndicator in
firstly {
updatePromiseBlock()
- }.done { (value: T) in
+ }.done(on: .main) { (value: T) in
modalActivityIndicator.dismiss {
completion(value)
}
diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m
index ff6a1c5a5d..c196759e22 100644
--- a/SignalMessaging/utils/ThreadUtil.m
+++ b/SignalMessaging/utils/ThreadUtil.m
@@ -4,7 +4,6 @@
#import "ThreadUtil.h"
#import "OWSQuotedReplyModel.h"
-#import
#import
#import
#import
diff --git a/SignalMessaging/utils/ThreadUtil.swift b/SignalMessaging/utils/ThreadUtil.swift
index 9a39e87f2b..ab7d3a5bd5 100644
--- a/SignalMessaging/utils/ThreadUtil.swift
+++ b/SignalMessaging/utils/ThreadUtil.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public extension ThreadUtil {
diff --git a/SignalServiceKit.podspec b/SignalServiceKit.podspec
index 8a92379aa2..954ac5c457 100644
--- a/SignalServiceKit.podspec
+++ b/SignalServiceKit.podspec
@@ -55,7 +55,6 @@ An Objective-C library for communicating with the Signal messaging service.
s.dependency 'SignalMetadataKit'
s.dependency 'GRDB.swift/SQLCipher'
s.dependency 'libwebp'
- s.dependency 'PromiseKit', "~> 6.0"
s.dependency 'YYImage/WebP'
s.dependency 'blurhash'
s.dependency 'SignalArgon2'
diff --git a/SignalServiceKit/src/Account/AccountServiceClient.swift b/SignalServiceKit/src/Account/AccountServiceClient.swift
index 765c9500d3..fda9ded4a8 100644
--- a/SignalServiceKit/src/Account/AccountServiceClient.swift
+++ b/SignalServiceKit/src/Account/AccountServiceClient.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// TODO define actual type, and validate length
public typealias IdentityKey = Data
@@ -26,7 +25,7 @@ public class AccountServiceClient: NSObject {
return serviceClient.requestVerificationCode(recipientId: recipientId,
preauthChallenge: preauthChallenge,
captchaToken: captchaToken,
- transport: transport).recover { error in
+ transport: transport).recover { error -> Void in
if error.httpStatusCode == 402 {
throw AccountServiceClientError.captchaRequired
}
diff --git a/SignalServiceKit/src/Account/CreatePreKeysOperation.swift b/SignalServiceKit/src/Account/CreatePreKeysOperation.swift
index a473819f54..9051ce543d 100644
--- a/SignalServiceKit/src/Account/CreatePreKeysOperation.swift
+++ b/SignalServiceKit/src/Account/CreatePreKeysOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc(SSKCreatePreKeysOperation)
public class CreatePreKeysOperation: OWSOperation {
diff --git a/SignalServiceKit/src/Account/RefreshPreKeysOperation.swift b/SignalServiceKit/src/Account/RefreshPreKeysOperation.swift
index 118143c776..af2d84bb61 100644
--- a/SignalServiceKit/src/Account/RefreshPreKeysOperation.swift
+++ b/SignalServiceKit/src/Account/RefreshPreKeysOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
// We generate 100 one-time prekeys at a time. We should replenish
// whenever ~2/3 of them have been consumed.
diff --git a/SignalServiceKit/src/Account/RotateSignedKeyOperation.swift b/SignalServiceKit/src/Account/RotateSignedKeyOperation.swift
index 97991d8355..61bf6d7c2d 100644
--- a/SignalServiceKit/src/Account/RotateSignedKeyOperation.swift
+++ b/SignalServiceKit/src/Account/RotateSignedKeyOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc(SSKRotateSignedPreKeyOperation)
public class RotateSignedPreKeyOperation: OWSOperation {
diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m
index 27844be4ed..3cf4a3ee72 100644
--- a/SignalServiceKit/src/Account/TSAccountManager.m
+++ b/SignalServiceKit/src/Account/TSAccountManager.m
@@ -4,7 +4,6 @@
#import "TSAccountManager.h"
#import
-#import
#import
#import
#import
diff --git a/SignalServiceKit/src/Account/TSAccountManager.swift b/SignalServiceKit/src/Account/TSAccountManager.swift
index 9cebd85d8f..c081018101 100644
--- a/SignalServiceKit/src/Account/TSAccountManager.swift
+++ b/SignalServiceKit/src/Account/TSAccountManager.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
public extension TSAccountManager {
diff --git a/SignalServiceKit/src/Contacts/Discovery/BulkUUIDLookup.swift b/SignalServiceKit/src/Contacts/Discovery/BulkUUIDLookup.swift
index b11f17c8cb..fa3fe983e5 100644
--- a/SignalServiceKit/src/Contacts/Discovery/BulkUUIDLookup.swift
+++ b/SignalServiceKit/src/Contacts/Discovery/BulkUUIDLookup.swift
@@ -2,8 +2,6 @@
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
//
-import PromiseKit
-
@objc
public class BulkUUIDLookup: NSObject {
diff --git a/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryOperation.swift b/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryOperation.swift
index 1278620ef0..ed889e9d42 100644
--- a/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryOperation.swift
+++ b/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
struct DiscoveredContactInfo: Hashable {
let e164: String?
diff --git a/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryTask.swift b/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryTask.swift
index f159052e97..b8a7dc61a5 100644
--- a/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryTask.swift
+++ b/SignalServiceKit/src/Contacts/Discovery/ContactDiscoveryTask.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import SignalCoreKit
/// The primary interface for discovering contacts through the CDS service
@@ -52,7 +51,7 @@ public class ContactDiscoveryTask: NSObject {
targetQueue: DispatchQueue? = nil,
database: SDSDatabaseStorage? = SDSDatabaseStorage.shared) -> Promise> {
guard e164FetchSet.count > 0 else {
- return .value(Set())
+ return Promise.value(Set())
}
if let retryAfterDate = Self.rateLimiter.currentRetryAfterDate(forCriticalPriority: isCriticalPriority) {
return Promise(error: ContactDiscoveryError.rateLimit(expiryDate: retryAfterDate))
@@ -68,7 +67,7 @@ public class ContactDiscoveryTask: NSObject {
let discoveryOperation = createContactDiscoveryOperation()
return discoveryOperation.perform(on: workQueue)
- }.map(on: workQueue) { (discoveredContacts) -> Set in
+ }.map(on: workQueue) { (discoveredContacts: Set) -> Set in
let discoveredIdentifiers = Set(discoveredContacts.compactMap { $0.e164 })
let discoveredAddresses = discoveredContacts
diff --git a/SignalServiceKit/src/Contacts/Discovery/ModernContactDiscoveryOperation.swift b/SignalServiceKit/src/Contacts/Discovery/ModernContactDiscoveryOperation.swift
index e9164d362a..43af4af56e 100644
--- a/SignalServiceKit/src/Contacts/Discovery/ModernContactDiscoveryOperation.swift
+++ b/SignalServiceKit/src/Contacts/Discovery/ModernContactDiscoveryOperation.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
struct CDSRegisteredContact: Hashable {
let signalUuid: UUID
@@ -29,7 +28,7 @@ class ModernContactDiscoveryOperation: ContactDiscovering {
.map { makeContactDiscoveryRequest(e164sToLookup: $0) }
// Then, wait for them all to be fulfilled before joining the subsets together
- return when(fulfilled: batchOperationPromises)
+ return Promise.when(fulfilled: batchOperationPromises)
}.map(on: queue) { (setArray) -> Set in
setArray.reduce(into: Set()) { (builder, cdsContactSubset) in
diff --git a/SignalServiceKit/src/Contacts/Discovery/UUIDBackfillTask.swift b/SignalServiceKit/src/Contacts/Discovery/UUIDBackfillTask.swift
index 7c77f2c516..dbd7b8b22f 100644
--- a/SignalServiceKit/src/Contacts/Discovery/UUIDBackfillTask.swift
+++ b/SignalServiceKit/src/Contacts/Discovery/UUIDBackfillTask.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc(OWSUUIDBackfillTask)
public class UUIDBackfillTask: NSObject {
diff --git a/SignalServiceKit/src/Devices/DeviceService.swift b/SignalServiceKit/src/Devices/DeviceService.swift
index c5626fbb34..5446965932 100644
--- a/SignalServiceKit/src/Devices/DeviceService.swift
+++ b/SignalServiceKit/src/Devices/DeviceService.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class DeviceService: NSObject {
diff --git a/SignalServiceKit/src/Devices/ProvisioningCipher.swift b/SignalServiceKit/src/Devices/ProvisioningCipher.swift
index 526b943d68..e2fd8be1ee 100644
--- a/SignalServiceKit/src/Devices/ProvisioningCipher.swift
+++ b/SignalServiceKit/src/Devices/ProvisioningCipher.swift
@@ -6,7 +6,6 @@ import Foundation
import SignalClient
import SignalMetadataKit
-import PromiseKit
import CommonCrypto
public struct ProvisionMessage {
diff --git a/SignalServiceKit/src/Messages/Attachments/BlurHash.swift b/SignalServiceKit/src/Messages/Attachments/BlurHash.swift
index 0bf27dfe0c..1e9b2a1aac 100644
--- a/SignalServiceKit/src/Messages/Attachments/BlurHash.swift
+++ b/SignalServiceKit/src/Messages/Attachments/BlurHash.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
import blurhash
@objc
@@ -39,31 +38,31 @@ public class BlurHash: NSObject {
}
public class func ensureBlurHash(for attachmentStream: TSAttachmentStream) -> Promise {
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
DispatchQueue.global().async {
guard attachmentStream.blurHash == nil else {
// Attachment already has a blurHash.
- resolver.fulfill(())
+ future.resolve()
return
}
guard attachmentStream.isVisualMedia else {
// We only generate a blurHash for visual media.
- resolver.fulfill(())
+ future.resolve()
return
}
guard attachmentStream.isValidVisualMedia else {
- resolver.reject(OWSAssertionError("Invalid attachment."))
+ future.reject(OWSAssertionError("Invalid attachment."))
return
}
// Use the smallest available thumbnail; quality doesn't matter.
// This is important for perf.
guard let thumbnail: UIImage = attachmentStream.thumbnailImageSmallSync() else {
- resolver.reject(OWSAssertionError("Could not load small thumbnail."))
+ future.reject(OWSAssertionError("Could not load small thumbnail."))
return
}
guard let normalized = normalize(image: thumbnail, backgroundColor: .white) else {
- resolver.reject(OWSAssertionError("Could not normalize thumbnail."))
+ future.reject(OWSAssertionError("Could not normalize thumbnail."))
return
}
// blurHash uses a DCT transform, so these are AC and DC components.
@@ -71,18 +70,18 @@ public class BlurHash: NSObject {
//
// https://github.com/woltapp/blurhash/blob/master/Algorithm.md
guard let blurHash = normalized.blurHash(numberOfComponents: (4, 3)) else {
- resolver.reject(OWSAssertionError("Could not generate blurHash."))
+ future.reject(OWSAssertionError("Could not generate blurHash."))
return
}
guard self.isValidBlurHash(blurHash) else {
- resolver.reject(OWSAssertionError("Generated invalid blurHash."))
+ future.reject(OWSAssertionError("Generated invalid blurHash."))
return
}
self.databaseStorage.write { transaction in
attachmentStream.update(withBlurHash: blurHash, transaction: transaction)
}
Logger.verbose("Generated blurHash.")
- resolver.fulfill(())
+ future.resolve()
}
return promise
diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift
index e9c358110f..85d4f19649 100644
--- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift
+++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentDownloads.swift
@@ -3,7 +3,6 @@
//
import Foundation
-import PromiseKit
@objc
public class OWSAttachmentDownloads: NSObject {
@@ -51,7 +50,7 @@ public class OWSAttachmentDownloads: NSObject {
let downloadBehavior: AttachmentDownloadBehavior
let promise: Promise
- let resolver: Resolver
+ let future: Future
var progress: CGFloat = 0
var attachmentId: AttachmentId { jobType.attachmentId }
@@ -63,9 +62,9 @@ public class OWSAttachmentDownloads: NSObject {
self.jobRequest = jobRequest
self.downloadBehavior = downloadBehavior
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
self.promise = promise
- self.resolver = resolver
+ self.future = future
}
func loadLatestAttachment(transaction: SDSAnyReadTransaction) -> TSAttachment? {
@@ -456,7 +455,7 @@ public class OWSAttachmentDownloads: NSObject {
}
// TODO: Should we fulfill() if the attachmentPointer no longer existed?
- job.resolver.fulfill(attachmentStream)
+ job.future.resolve(attachmentStream)
markJobComplete(job, isAttachmentDownloaded: true)
}
@@ -489,7 +488,7 @@ public class OWSAttachmentDownloads: NSObject {
}
}
- job.resolver.reject(error)
+ job.future.reject(error)
markJobComplete(job, isAttachmentDownloaded: false)
}
@@ -694,10 +693,10 @@ public extension OWSAttachmentDownloads {
public extension OWSAttachmentDownloads {
func enqueueHeadlessDownloadPromise(attachmentPointer: TSAttachmentPointer) -> Promise {
- return Promise { resolver in
+ return Promise { future in
self.enqueueHeadlessDownload(attachmentPointer: attachmentPointer,
- success: resolver.fulfill,
- failure: resolver.reject)
+ success: future.resolve,
+ failure: future.reject)
}.map { attachments in
assert(attachments.count == 1)
guard let attachment = attachments.first else {
@@ -758,7 +757,7 @@ public extension OWSAttachmentDownloads {
do {
let finder = GRDBInteractionFinder(threadUniqueId: thread.uniqueId)
try finder.enumerateMessagesWithAttachments(transaction: transaction.unwrapGrdbRead) { (message, _) in
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
promises.append(promise)
self.enqueueDownloadOfAttachments(forMessageId: message.uniqueId,
attachmentGroup: .allAttachmentsIncoming,
@@ -768,10 +767,10 @@ public extension OWSAttachmentDownloads {
unfairLock.withLock {
attachmentStreams.append(contentsOf: downloadedAttachments)
}
- resolver.fulfill(())
+ future.resolve()
},
failure: { error in
- resolver.reject(error)
+ future.reject(error)
})
}
@@ -781,8 +780,8 @@ public extension OWSAttachmentDownloads {
// Block until _all_ promises have either succeeded or failed.
_ = firstly(on: Self.serialQueue) {
- when(fulfilled: promises)
- }.done(on: Self.serialQueue) { _ in
+ Promise.when(fulfilled: promises)
+ }.done(on: Self.serialQueue) {
let attachmentStreamsCopy = unfairLock.withLock { attachmentStreams }
Logger.info("Successfully downloaded attachments for whitelisted thread: \(attachmentStreamsCopy.count).")
}.catch(on: Self.serialQueue) { error in
@@ -1139,8 +1138,8 @@ public extension OWSAttachmentDownloads {
// Block until _all_ promises have either succeeded or failed.
_ = firstly(on: Self.serialQueue) {
- when(fulfilled: promises)
- }.done(on: Self.serialQueue) { _ in
+ Promise.when(fulfilled: promises)
+ }.done(on: Self.serialQueue) {
let attachmentStreamsCopy = unfairLock.withLock { attachmentStreams }
Logger.info("Attachment downloads succeeded: \(attachmentStreamsCopy.count).")
@@ -1220,7 +1219,7 @@ public extension OWSAttachmentDownloads {
resumeData: Data? = nil,
attemptIndex: UInt = 0) -> Promise {
- let (promise, resolver) = Promise.pending()
+ let (promise, future) = Promise.pending()
firstly(on: Self.serialQueue) { () -> Promise in
let attachmentPointer = downloadState.attachmentPointer
@@ -1234,7 +1233,7 @@ public extension OWSAttachmentDownloads {
self.handleDownloadProgress(downloadState: downloadState,
task: task,
progress: progress,
- resolver: resolver)
+ future: future)
}
if let resumeData = resumeData {
@@ -1271,7 +1270,7 @@ public extension OWSAttachmentDownloads {
return firstly {
// Wait briefly before retrying.
- after(seconds: 0.25)
+ Guarantee.after(seconds: 0.25)
}.then { () -> Promise