diff options
| author | Sajad Vishkai <sajaclvishkai@gmail.com> | 2022-09-26 15:27:15 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-09-26 16:31:22 +0200 |
| commit | 6ce197773c98803ffc2ee8bb68b3b4a2eb9945e7 (patch) | |
| tree | e83fb435fb72b122ed4f6c3f11ad8397f48be171 | |
| parent | e81679ab4d965bc179a0298888228e46b94b9152 (diff) | |
| download | mullvadvpn-6ce197773c98803ffc2ee8bb68b3b4a2eb9945e7.tar.xz mullvadvpn-6ce197773c98803ffc2ee8bb68b3b4a2eb9945e7.zip | |
Update AppDelegate.swift
Dropped application(
_ application: UIApplication,
performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult)
-> Void
)
In favor of dropping iOS 12.
| -rw-r--r-- | ios/MullvadVPN/AppDelegate.swift | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index b5190b83bb..66a99cc302 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -80,94 +80,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } } - func application( - _ application: UIApplication, - performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) - -> Void - ) { - logger.debug("Start background refresh.") - - let updateAddressCacheOperation = ResultBlockOperation<Bool, Error> { operation in - let handle = AddressCache.Tracker.shared.updateEndpoints { completion in - operation.finish(completion: completion) - } - - operation.addCancellationBlock { - handle.cancel() - } - } - - let updateRelaysOperation = ResultBlockOperation<RelayCache.FetchResult, Error> - { operation in - let handle = RelayCache.Tracker.shared.updateRelays { completion in - operation.finish(completion: completion) - } - - operation.addCancellationBlock { - handle.cancel() - } - } - - let rotatePrivateKeyOperation = ResultBlockOperation<Bool, Error> { operation in - let handle = TunnelManager.shared.rotatePrivateKey(forceRotate: false) { completion in - operation.finish(completion: completion) - } - - operation.addCancellationBlock { - handle.cancel() - } - } - rotatePrivateKeyOperation.addDependencies([ - updateRelaysOperation, - updateAddressCacheOperation, - ]) - - let operations = [ - updateAddressCacheOperation, - updateRelaysOperation, - rotatePrivateKeyOperation, - ] - - let completeOperation = TransformOperation<UIBackgroundFetchResult, Void, Never>( - dispatchQueue: .main - ) - - completeOperation.setExecutionBlock { backgroundFetchResult in - self.logger.debug("Finish background refresh. Status: \(backgroundFetchResult).") - - completionHandler(backgroundFetchResult) - } - - completeOperation.injectMany(context: [UIBackgroundFetchResult]()) - .injectCompletion(from: updateAddressCacheOperation, via: { results, completion in - results.append(completion.backgroundFetchResult { $0 }) - }) - .injectCompletion(from: updateRelaysOperation, via: { results, completion in - results.append(completion.backgroundFetchResult { $0 == .newContent }) - }) - .injectCompletion(from: rotatePrivateKeyOperation, via: { results, completion in - results.append(completion.backgroundFetchResult { $0 }) - }) - .reduce { operationResults in - let initialResult = operationResults.first ?? .failed - let backgroundFetchResult = operationResults - .reduce(initialResult) { partialResult, other in - return partialResult.combine(with: other) - } - - return backgroundFetchResult - } - - let groupOperation = GroupOperation(operations: operations) - groupOperation.addObserver( - BackgroundObserver(name: "Background refresh", cancelUponExpiration: true) - ) - - let operationQueue = AsyncOperationQueue() - operationQueue.addOperation(groupOperation) - operationQueue.addOperation(completeOperation) - } - // MARK: - UISceneSession lifecycle func application( |
