diff options
| -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( |
