diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index ac672d053..44b7d1e47 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -351,7 +351,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, client: OAuthAuthorizationClient, accountType: AccountType, transport: Transport = URLSession.webserviceTransport(), - completionHandler: @escaping (Result) -> ()) { + completion: @escaping (Result) -> ()) { let grantingType: OAuthAuthorizationGranting.Type switch accountType { @@ -361,7 +361,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, fatalError("\(accountType) does not support OAuth authorization code granting.") } - grantingType.requestOAuthAccessToken(with: response, transport: transport, completionHandler: completionHandler) + grantingType.requestOAuthAccessToken(with: response, transport: transport, completion: completion) } public func refreshAll(completion: @escaping (Result) -> Void) { @@ -754,12 +754,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, return updatedArticles } - func ensureStatuses(_ articleIDs: Set, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completionHandler: VoidCompletionBlock? = nil) { + func ensureStatuses(_ articleIDs: Set, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completion: VoidCompletionBlock? = nil) { guard !articleIDs.isEmpty else { - completionHandler?() + completion?() return } - database.ensureStatuses(articleIDs, defaultRead, statusKey, flag, completionHandler: completionHandler) + database.ensureStatuses(articleIDs, defaultRead, statusKey, flag, completion: completion) } /// Update statuses — set a key and value. This updates the database, and sends a .StatusesDidChange notification. @@ -767,10 +767,10 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, // TODO: https://github.com/brentsimmons/NetNewsWire/issues/1420 } - /// Fetch statuses for the specified articleIDs. The completionHandler will get nil if the app is suspended. + /// Fetch statuses for the specified articleIDs. The completion handler will get nil if the app is suspended. /// To update the properties in the database, call the update method that takes Set as first parameter. - func fetchStatuses(articleIDs: Set, createIfNeeded: Bool, completionHandler: @escaping (Set?) -> Void) { - database.fetchStatuses(articleIDs: articleIDs, createIfNeeded: createIfNeeded, callback: completionHandler) + func fetchStatuses(articleIDs: Set, createIfNeeded: Bool, completion: @escaping (Set?) -> Void) { + database.fetchStatuses(articleIDs: articleIDs, createIfNeeded: createIfNeeded, callback: completion) } /// Empty caches that can reasonably be emptied. Call when the app goes in the background, for instance. diff --git a/Frameworks/Account/AccountTests/Feedly/FeedlyAddNewFeedOperationTests.swift b/Frameworks/Account/AccountTests/Feedly/FeedlyAddNewFeedOperationTests.swift index fba479fd2..c218e8f07 100644 --- a/Frameworks/Account/AccountTests/Feedly/FeedlyAddNewFeedOperationTests.swift +++ b/Frameworks/Account/AccountTests/Feedly/FeedlyAddNewFeedOperationTests.swift @@ -172,14 +172,14 @@ class FeedlyAddNewFeedOperationTests: XCTestCase { var addFeedExpectation: XCTestExpectation? var parameterTester: ((FeedlyFeedResourceId, String?, String) -> ())? - func addFeed(with feedId: FeedlyFeedResourceId, title: String?, toCollectionWith collectionId: String, completionHandler: @escaping (Result<[FeedlyFeed], Error>) -> ()) { + func addFeed(with feedId: FeedlyFeedResourceId, title: String?, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> ()) { guard let result = mockResult else { XCTFail("Missing mock result. Test may time out because the completion will not be called.") return } parameterTester?(feedId, title, collectionId) DispatchQueue.main.async { - completionHandler(result) + completion(result) self.addFeedExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/FeedlyLogoutOperationTests.swift b/Frameworks/Account/AccountTests/Feedly/FeedlyLogoutOperationTests.swift index 95c3c3156..6198bad87 100644 --- a/Frameworks/Account/AccountTests/Feedly/FeedlyLogoutOperationTests.swift +++ b/Frameworks/Account/AccountTests/Feedly/FeedlyLogoutOperationTests.swift @@ -38,13 +38,13 @@ class FeedlyLogoutOperationTests: XCTestCase { var mockResult: Result? var logoutExpectation: XCTestExpectation? - func logout(completionHandler: @escaping (Result) -> ()) { + func logout(completion: @escaping (Result) -> ()) { guard let result = mockResult else { XCTFail("Missing mock result. Test may time out because the completion will not be called.") return } DispatchQueue.main.async { - completionHandler(result) + completion(result) self.logoutExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/FeedlyRefreshAccessTokenOperationTests.swift b/Frameworks/Account/AccountTests/Feedly/FeedlyRefreshAccessTokenOperationTests.swift index 3e1e5f07e..ee4991531 100644 --- a/Frameworks/Account/AccountTests/Feedly/FeedlyRefreshAccessTokenOperationTests.swift +++ b/Frameworks/Account/AccountTests/Feedly/FeedlyRefreshAccessTokenOperationTests.swift @@ -32,7 +32,7 @@ class FeedlyRefreshAccessTokenOperationTests: XCTestCase { var refreshAccessTokenExpectation: XCTestExpectation? var parameterTester: ((String, OAuthAuthorizationClient) -> ())? - func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completionHandler: @escaping (Result) -> ()) { + func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result) -> ()) { guard let result = mockResult else { XCTFail("Missing mock result. Test may time out because the completion will not be called.") @@ -40,7 +40,7 @@ class FeedlyRefreshAccessTokenOperationTests: XCTestCase { } parameterTester?(refreshToken, client) DispatchQueue.main.async { - completionHandler(result) + completion(result) self.refreshAccessTokenExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/TestGetCollectionsService.swift b/Frameworks/Account/AccountTests/Feedly/TestGetCollectionsService.swift index e9ec46176..7f6b89813 100644 --- a/Frameworks/Account/AccountTests/Feedly/TestGetCollectionsService.swift +++ b/Frameworks/Account/AccountTests/Feedly/TestGetCollectionsService.swift @@ -13,13 +13,13 @@ final class TestGetCollectionsService: FeedlyGetCollectionsService { var mockResult: Result<[FeedlyCollection], Error>? var getCollectionsExpectation: XCTestExpectation? - func getCollections(completionHandler: @escaping (Result<[FeedlyCollection], Error>) -> ()) { + func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> ()) { guard let result = mockResult else { XCTFail("Missing mock result. Test may time out because the completion will not be called.") return } DispatchQueue.main.async { - completionHandler(result) + completion(result) self.getCollectionsExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamContentsService.swift b/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamContentsService.swift index 6d56d218c..979134404 100644 --- a/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamContentsService.swift +++ b/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamContentsService.swift @@ -65,7 +65,7 @@ final class TestGetPagedStreamContentsService: FeedlyGetStreamContentsService { return "\(stream.id)@\(continuation ?? "")" } - func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) { + func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) { let key = TestGetPagedStreamContentsService.getPagingKey(for: resource, continuation: continuation) guard let page = pages[key] else { XCTFail("Missing page for \(resource.id) and continuation \(String(describing: continuation)). Test may time out because the completion will not be called.") @@ -73,7 +73,7 @@ final class TestGetPagedStreamContentsService: FeedlyGetStreamContentsService { } parameterTester?(resource, continuation, newerThan, unreadOnly) DispatchQueue.main.async { - completionHandler(.success(page)) + completion(.success(page)) self.getStreamContentsExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamIdsService.swift b/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamIdsService.swift index dda3afd60..da09e094b 100644 --- a/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamIdsService.swift +++ b/Frameworks/Account/AccountTests/Feedly/TestGetPagedStreamIdsService.swift @@ -41,7 +41,7 @@ final class TestGetPagedStreamIdsService: FeedlyGetStreamIdsService { return "\(stream.id)@\(continuation ?? "")" } - func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) { + func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) { let key = TestGetPagedStreamIdsService.getPagingKey(for: resource, continuation: continuation) guard let page = pages[key] else { XCTFail("Missing page for \(resource.id) and continuation \(String(describing: continuation)). Test may time out because the completion will not be called.") @@ -49,7 +49,7 @@ final class TestGetPagedStreamIdsService: FeedlyGetStreamIdsService { } parameterTester?(resource, continuation, newerThan, unreadOnly) DispatchQueue.main.async { - completionHandler(.success(page)) + completion(.success(page)) self.getStreamIdsExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/TestGetStreamContentsService.swift b/Frameworks/Account/AccountTests/Feedly/TestGetStreamContentsService.swift index dd4636079..c62fba4c5 100644 --- a/Frameworks/Account/AccountTests/Feedly/TestGetStreamContentsService.swift +++ b/Frameworks/Account/AccountTests/Feedly/TestGetStreamContentsService.swift @@ -15,14 +15,14 @@ final class TestGetStreamContentsService: FeedlyGetStreamContentsService { var parameterTester: ((FeedlyResourceId, String?, Date?, Bool?) -> ())? var getStreamContentsExpectation: XCTestExpectation? - func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) { + func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) { guard let result = mockResult else { XCTFail("Missing mock result. Test may time out because the completion will not be called.") return } parameterTester?(resource, continuation, newerThan, unreadOnly) DispatchQueue.main.async { - completionHandler(result) + completion(result) self.getStreamContentsExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/TestGetStreamIdsService.swift b/Frameworks/Account/AccountTests/Feedly/TestGetStreamIdsService.swift index ef35b7f53..5ae0de1c4 100644 --- a/Frameworks/Account/AccountTests/Feedly/TestGetStreamIdsService.swift +++ b/Frameworks/Account/AccountTests/Feedly/TestGetStreamIdsService.swift @@ -15,14 +15,14 @@ final class TestGetStreamIdsService: FeedlyGetStreamIdsService { var parameterTester: ((FeedlyResourceId, String?, Date?, Bool?) -> ())? var getStreamIdsExpectation: XCTestExpectation? - func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) { + func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) { guard let result = mockResult else { XCTFail("Missing mock result. Test may time out because the completion will not be called.") return } parameterTester?(resource, continuation, newerThan, unreadOnly) DispatchQueue.main.async { - completionHandler(result) + completion(result) self.getStreamIdsExpectation?.fulfill() } } diff --git a/Frameworks/Account/AccountTests/Feedly/TestMarkArticlesService.swift b/Frameworks/Account/AccountTests/Feedly/TestMarkArticlesService.swift index 1f83f2ca0..6bc715275 100644 --- a/Frameworks/Account/AccountTests/Feedly/TestMarkArticlesService.swift +++ b/Frameworks/Account/AccountTests/Feedly/TestMarkArticlesService.swift @@ -15,11 +15,11 @@ class TestMarkArticlesService: FeedlyMarkArticlesService { var parameterTester: ((Set, FeedlyMarkAction) -> ())? var mockResult: Result = .success(()) - func mark(_ articleIds: Set, as action: FeedlyMarkAction, completionHandler: @escaping (Result) -> ()) { + func mark(_ articleIds: Set, as action: FeedlyMarkAction, completion: @escaping (Result) -> ()) { DispatchQueue.main.async { self.parameterTester?(articleIds, action) - completionHandler(self.mockResult) + completion(self.mockResult) self.didMarkExpectation?.fulfill() } } diff --git a/Frameworks/Account/Feedly/FeedlyAPICaller.swift b/Frameworks/Account/Feedly/FeedlyAPICaller.swift index 47795d659..afa4d7747 100644 --- a/Frameworks/Account/Feedly/FeedlyAPICaller.swift +++ b/Frameworks/Account/Feedly/FeedlyAPICaller.swift @@ -69,16 +69,16 @@ final class FeedlyAPICaller { isSuspended = false } - func importOpml(_ opmlData: Data, completionHandler: @escaping (Result) -> ()) { + func importOpml(_ opmlData: Data, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } var components = baseUrlComponents @@ -99,26 +99,26 @@ final class FeedlyAPICaller { switch result { case .success(let (httpResponse, _)): if httpResponse.statusCode == 200 { - completionHandler(.success(())) + completion(.success(())) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } - func createCollection(named label: String, completionHandler: @escaping (Result) -> ()) { + func createCollection(named label: String, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } var components = baseUrlComponents @@ -143,7 +143,7 @@ final class FeedlyAPICaller { request.httpBody = data } catch { return DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } } @@ -151,26 +151,26 @@ final class FeedlyAPICaller { switch result { case .success(let (httpResponse, collections)): if httpResponse.statusCode == 200, let collection = collections?.first { - completionHandler(.success(collection)) + completion(.success(collection)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } - func renameCollection(with id: String, to name: String, completionHandler: @escaping (Result) -> ()) { + func renameCollection(with id: String, to name: String, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } var components = baseUrlComponents @@ -196,7 +196,7 @@ final class FeedlyAPICaller { request.httpBody = data } catch { return DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } } @@ -204,12 +204,12 @@ final class FeedlyAPICaller { switch result { case .success(let (httpResponse, collections)): if httpResponse.statusCode == 200, let collection = collections?.first { - completionHandler(.success(collection)) + completion(.success(collection)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -218,21 +218,21 @@ final class FeedlyAPICaller { return pathComponent.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) } - func deleteCollection(with id: String, completionHandler: @escaping (Result) -> ()) { + func deleteCollection(with id: String, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } guard let encodedId = encodeForURLPath(id) else { return DispatchQueue.main.async { - completionHandler(.failure(FeedlyAccountDelegateError.unexpectedResourceId(id))) + completion(.failure(FeedlyAccountDelegateError.unexpectedResourceId(id))) } } var components = baseUrlComponents @@ -252,38 +252,38 @@ final class FeedlyAPICaller { switch result { case .success(let (httpResponse, _)): if httpResponse.statusCode == 200 { - completionHandler(.success(())) + completion(.success(())) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } - func removeFeed(_ feedId: String, fromCollectionWith collectionId: String, completionHandler: @escaping (Result) -> ()) { + func removeFeed(_ feedId: String, fromCollectionWith collectionId: String, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } guard let encodedCollectionId = encodeForURLPath(collectionId) else { return DispatchQueue.main.async { - completionHandler(.failure(FeedlyAccountDelegateError.unexpectedResourceId(collectionId))) + completion(.failure(FeedlyAccountDelegateError.unexpectedResourceId(collectionId))) } } guard let encodedFeedId = encodeForURLPath(feedId) else { return DispatchQueue.main.async { - completionHandler(.failure(FeedlyAccountDelegateError.unexpectedResourceId(feedId))) + completion(.failure(FeedlyAccountDelegateError.unexpectedResourceId(feedId))) } } @@ -304,12 +304,12 @@ final class FeedlyAPICaller { switch result { case .success(let httpResponse, _): if httpResponse.statusCode == 200 { - completionHandler(.success(())) + completion(.success(())) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -317,22 +317,22 @@ final class FeedlyAPICaller { extension FeedlyAPICaller: FeedlyAddFeedToCollectionService { - func addFeed(with feedId: FeedlyFeedResourceId, title: String? = nil, toCollectionWith collectionId: String, completionHandler: @escaping (Result<[FeedlyFeed], Error>) -> ()) { + func addFeed(with feedId: FeedlyFeedResourceId, title: String? = nil, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } guard let encodedId = encodeForURLPath(collectionId) else { return DispatchQueue.main.async { - completionHandler(.failure(FeedlyAccountDelegateError.unexpectedResourceId(collectionId))) + completion(.failure(FeedlyAccountDelegateError.unexpectedResourceId(collectionId))) } } var components = baseUrlComponents @@ -358,7 +358,7 @@ extension FeedlyAPICaller: FeedlyAddFeedToCollectionService { request.httpBody = data } catch { return DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } } @@ -366,12 +366,12 @@ extension FeedlyAPICaller: FeedlyAddFeedToCollectionService { switch result { case .success(_, let collectionFeeds): if let feeds = collectionFeeds { - completionHandler(.success(feeds)) + completion(.success(feeds)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -398,10 +398,10 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { typealias AccessTokenResponse = FeedlyOAuthAccessTokenResponse - func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completionHandler: @escaping (Result) -> ()) { + func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } @@ -423,7 +423,7 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { request.httpBody = try encoder.encode(authorizationRequest) } catch { DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } return } @@ -432,12 +432,12 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { switch result { case .success(let (_, tokenResponse)): if let response = tokenResponse { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -445,10 +445,10 @@ extension FeedlyAPICaller: OAuthAuthorizationCodeGrantRequesting { extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting { - func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completionHandler: @escaping (Result) -> ()) { + func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } @@ -470,7 +470,7 @@ extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting { request.httpBody = try encoder.encode(refreshRequest) } catch { DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } return } @@ -479,12 +479,12 @@ extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting { switch result { case .success(let (_, tokenResponse)): if let response = tokenResponse { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -492,16 +492,16 @@ extension FeedlyAPICaller: OAuthAcessTokenRefreshRequesting { extension FeedlyAPICaller: FeedlyGetCollectionsService { - func getCollections(completionHandler: @escaping (Result<[FeedlyCollection], Error>) -> ()) { + func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } var components = baseUrlComponents @@ -520,12 +520,12 @@ extension FeedlyAPICaller: FeedlyGetCollectionsService { switch result { case .success(let (_, collections)): if let response = collections { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -533,16 +533,16 @@ extension FeedlyAPICaller: FeedlyGetCollectionsService { extension FeedlyAPICaller: FeedlyGetStreamContentsService { - func getStreamContents(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) { + func getStreamContents(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } @@ -588,12 +588,12 @@ extension FeedlyAPICaller: FeedlyGetStreamContentsService { switch result { case .success(let (_, collections)): if let response = collections { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -601,16 +601,16 @@ extension FeedlyAPICaller: FeedlyGetStreamContentsService { extension FeedlyAPICaller: FeedlyGetStreamIdsService { - func getStreamIds(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) { + func getStreamIds(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } @@ -656,12 +656,12 @@ extension FeedlyAPICaller: FeedlyGetStreamIdsService { switch result { case .success(let (_, collections)): if let response = collections { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -669,16 +669,16 @@ extension FeedlyAPICaller: FeedlyGetStreamIdsService { extension FeedlyAPICaller: FeedlyGetEntriesService { - func getEntries(for ids: Set, completionHandler: @escaping (Result<[FeedlyEntry], Error>) -> ()) { + func getEntries(for ids: Set, completion: @escaping (Result<[FeedlyEntry], Error>) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } @@ -698,7 +698,7 @@ extension FeedlyAPICaller: FeedlyGetEntriesService { request.httpBody = data } catch { return DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } } @@ -711,12 +711,12 @@ extension FeedlyAPICaller: FeedlyGetEntriesService { switch result { case .success(let (_, entries)): if let response = entries { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -730,16 +730,16 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService { var entryIds: [String] } - func mark(_ articleIds: Set, as action: FeedlyMarkAction, completionHandler: @escaping (Result) -> ()) { + func mark(_ articleIds: Set, as action: FeedlyMarkAction, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } var components = baseUrlComponents @@ -762,7 +762,7 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService { request.httpBody = data } catch { return DispatchQueue.main.async { - completionHandler(.failure(error)) + completion(.failure(error)) } } @@ -770,12 +770,12 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService { switch result { case .success(let (httpResponse, _)): if httpResponse.statusCode == 200 { - completionHandler(.success(())) + completion(.success(())) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -783,11 +783,11 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService { extension FeedlyAPICaller: FeedlySearchService { - func getFeeds(for query: String, count: Int, locale: String, completionHandler: @escaping (Result) -> ()) { + func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } @@ -814,12 +814,12 @@ extension FeedlyAPICaller: FeedlySearchService { switch result { case .success(let (_, searchResponse)): if let response = searchResponse { - completionHandler(.success(response)) + completion(.success(response)) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } @@ -827,16 +827,16 @@ extension FeedlyAPICaller: FeedlySearchService { extension FeedlyAPICaller: FeedlyLogoutService { - func logout(completionHandler: @escaping (Result) -> ()) { + func logout(completion: @escaping (Result) -> ()) { guard !isSuspended else { return DispatchQueue.main.async { - completionHandler(.failure(TransportError.suspended)) + completion(.failure(TransportError.suspended)) } } guard let accessToken = credentials?.secret else { return DispatchQueue.main.async { - completionHandler(.failure(CredentialsError.incompleteCredentials)) + completion(.failure(CredentialsError.incompleteCredentials)) } } var components = baseUrlComponents @@ -856,12 +856,12 @@ extension FeedlyAPICaller: FeedlyLogoutService { switch result { case .success(let (httpResponse, _)): if httpResponse.statusCode == 200 { - completionHandler(.success(())) + completion(.success(())) } else { - completionHandler(.failure(URLError(.cannotDecodeContentData))) + completion(.failure(URLError(.cannotDecodeContentData))) } case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } diff --git a/Frameworks/Account/Feedly/FeedlyAccountDelegate+OAuth.swift b/Frameworks/Account/Feedly/FeedlyAccountDelegate+OAuth.swift index f0c3bae48..f9165f06e 100644 --- a/Frameworks/Account/Feedly/FeedlyAccountDelegate+OAuth.swift +++ b/Frameworks/Account/Feedly/FeedlyAccountDelegate+OAuth.swift @@ -37,7 +37,7 @@ extension FeedlyAccountDelegate: OAuthAuthorizationGranting { return FeedlyAPICaller.authorizationCodeUrlRequest(for: authorizationRequest, baseUrlComponents: baseURLComponents) } - static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completionHandler: @escaping (Result) -> ()) { + static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completion: @escaping (Result) -> ()) { let client = environment.oauthAuthorizationClient let request = OAuthAccessTokenRequest(authorizationResponse: response, scope: oauthAuthorizationGrantScope, @@ -57,17 +57,17 @@ extension FeedlyAccountDelegate: OAuthAuthorizationGranting { let grant = OAuthAuthorizationGrant(accessToken: accessToken, refreshToken: refreshToken) - completionHandler(.success(grant)) + completion(.success(grant)) case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } } extension FeedlyAccountDelegate: OAuthAccessTokenRefreshing { - func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completionHandler: @escaping (Result) -> ()) { + func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result) -> ()) { let request = OAuthRefreshAccessTokenRequest(refreshToken: refreshToken, scope: nil, client: client) caller.refreshAccessToken(request) { result in @@ -84,10 +84,10 @@ extension FeedlyAccountDelegate: OAuthAccessTokenRefreshing { let grant = OAuthAuthorizationGrant(accessToken: accessToken, refreshToken: refreshToken) - completionHandler(.success(grant)) + completion(.success(grant)) case .failure(let error): - completionHandler(.failure(error)) + completion(.failure(error)) } } } diff --git a/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift b/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift index bc73c6f3e..28bcafb7f 100644 --- a/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift +++ b/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift @@ -84,7 +84,7 @@ public final class OAuthAccountAuthorizationOperation: Operation, ASWebAuthentic let response = try OAuthAuthorizationResponse(url: url, client: oauthClient) - Account.requestOAuthAccessToken(with: response, client: oauthClient, accountType: accountType, completionHandler: didEndRequestingAccessToken(_:)) + Account.requestOAuthAccessToken(with: response, client: oauthClient, accountType: accountType, completion: didEndRequestingAccessToken(_:)) } catch is ASWebAuthenticationSessionError { didFinish() // Primarily, cancellation. diff --git a/Frameworks/Account/Feedly/OAuthAcessTokenRefreshing.swift b/Frameworks/Account/Feedly/OAuthAcessTokenRefreshing.swift index 811f004fa..f7b862375 100644 --- a/Frameworks/Account/Feedly/OAuthAcessTokenRefreshing.swift +++ b/Frameworks/Account/Feedly/OAuthAcessTokenRefreshing.swift @@ -35,12 +35,12 @@ public protocol OAuthAcessTokenRefreshRequesting { /// Access tokens expire. Perform a request for a fresh access token given the long life refresh token received when authorization was granted. /// - Parameter refreshRequest: The refresh token and other information the authorization server requires to grant the client fresh access tokens on the user's behalf. - /// - Parameter completionHandler: On success, the access token response appropriate for concrete type's service. Both the access and refresh token should be stored, preferrably on the Keychain. On failure, possibly a `URLError` or `OAuthAuthorizationErrorResponse` value. - func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completionHandler: @escaping (Result) -> ()) + /// - Parameter completion: On success, the access token response appropriate for concrete type's service. Both the access and refresh token should be stored, preferrably on the Keychain. On failure, possibly a `URLError` or `OAuthAuthorizationErrorResponse` value. + func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result) -> ()) } /// Implemented by concrete types to perform the actual request. protocol OAuthAccessTokenRefreshing: class { - func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completionHandler: @escaping (Result) -> ()) + func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result) -> ()) } diff --git a/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift b/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift index 3f1aabbaf..735f33bff 100644 --- a/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift +++ b/Frameworks/Account/Feedly/OAuthAuthorizationCodeGranting.swift @@ -160,13 +160,13 @@ public protocol OAuthAuthorizationCodeGrantRequesting { /// Performs the request for the access token given an authorization code. /// - Parameter authorizationRequest: The authorization code and other information the authorization server requires to grant the client access tokens on the user's behalf. - /// - Parameter completionHandler: On success, the access token response appropriate for concrete type's service. On failure, possibly a `URLError` or `OAuthAuthorizationErrorResponse` value. - func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completionHandler: @escaping (Result) -> ()) + /// - Parameter completion: On success, the access token response appropriate for concrete type's service. On failure, possibly a `URLError` or `OAuthAuthorizationErrorResponse` value. + func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completion: @escaping (Result) -> ()) } protocol OAuthAuthorizationGranting: AccountDelegate { static func oauthAuthorizationCodeGrantRequest() -> URLRequest - static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completionHandler: @escaping (Result) -> ()) + static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completion: @escaping (Result) -> ()) } diff --git a/Frameworks/Account/Feedly/Operations/FeedlyAddFeedToCollectionOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyAddFeedToCollectionOperation.swift index eec23c32b..1228fa1e8 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyAddFeedToCollectionOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyAddFeedToCollectionOperation.swift @@ -9,7 +9,7 @@ import Foundation protocol FeedlyAddFeedToCollectionService { - func addFeed(with feedId: FeedlyFeedResourceId, title: String?, toCollectionWith collectionId: String, completionHandler: @escaping (Result<[FeedlyFeed], Error>) -> ()) + func addFeed(with feedId: FeedlyFeedResourceId, title: String?, toCollectionWith collectionId: String, completion: @escaping (Result<[FeedlyFeed], Error>) -> ()) } final class FeedlyAddFeedToCollectionOperation: FeedlyOperation, FeedlyFeedsAndFoldersProviding, FeedlyResourceProviding { diff --git a/Frameworks/Account/Feedly/Operations/FeedlyLogoutOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlyLogoutOperation.swift index 53e640799..80e607c18 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlyLogoutOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlyLogoutOperation.swift @@ -10,7 +10,7 @@ import Foundation import os.log protocol FeedlyLogoutService { - func logout(completionHandler: @escaping (Result) -> ()) + func logout(completion: @escaping (Result) -> ()) } final class FeedlyLogoutOperation: FeedlyOperation { @@ -30,7 +30,7 @@ final class FeedlyLogoutOperation: FeedlyOperation { return } os_log("Requesting logout of %{public}@ account.", "\(account.type)") - service.logout(completionHandler: didCompleteLogout(_:)) + service.logout(completion: didCompleteLogout(_:)) } func didCompleteLogout(_ result: Result) { diff --git a/Frameworks/Account/Feedly/Operations/FeedlySearchOperation.swift b/Frameworks/Account/Feedly/Operations/FeedlySearchOperation.swift index e9b712496..3251a9c38 100644 --- a/Frameworks/Account/Feedly/Operations/FeedlySearchOperation.swift +++ b/Frameworks/Account/Feedly/Operations/FeedlySearchOperation.swift @@ -9,7 +9,7 @@ import Foundation protocol FeedlySearchService: class { - func getFeeds(for query: String, count: Int, locale: String, completionHandler: @escaping (Result) -> ()) + func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result) -> ()) } protocol FeedlySearchOperationDelegate: class { diff --git a/Frameworks/Account/Feedly/Services/FeedlyGetCollectionsService.swift b/Frameworks/Account/Feedly/Services/FeedlyGetCollectionsService.swift index 15e8a5451..5714e63c5 100644 --- a/Frameworks/Account/Feedly/Services/FeedlyGetCollectionsService.swift +++ b/Frameworks/Account/Feedly/Services/FeedlyGetCollectionsService.swift @@ -9,5 +9,5 @@ import Foundation protocol FeedlyGetCollectionsService: class { - func getCollections(completionHandler: @escaping (Result<[FeedlyCollection], Error>) -> ()) + func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> ()) } diff --git a/Frameworks/Account/Feedly/Services/FeedlyGetEntriesService.swift b/Frameworks/Account/Feedly/Services/FeedlyGetEntriesService.swift index 727fc28bc..5acc75663 100644 --- a/Frameworks/Account/Feedly/Services/FeedlyGetEntriesService.swift +++ b/Frameworks/Account/Feedly/Services/FeedlyGetEntriesService.swift @@ -9,5 +9,5 @@ import Foundation protocol FeedlyGetEntriesService: class { - func getEntries(for ids: Set, completionHandler: @escaping (Result<[FeedlyEntry], Error>) -> ()) + func getEntries(for ids: Set, completion: @escaping (Result<[FeedlyEntry], Error>) -> ()) } diff --git a/Frameworks/Account/Feedly/Services/FeedlyGetStreamContentsService.swift b/Frameworks/Account/Feedly/Services/FeedlyGetStreamContentsService.swift index c24e4b4c8..ce80d59dc 100644 --- a/Frameworks/Account/Feedly/Services/FeedlyGetStreamContentsService.swift +++ b/Frameworks/Account/Feedly/Services/FeedlyGetStreamContentsService.swift @@ -9,5 +9,5 @@ import Foundation protocol FeedlyGetStreamContentsService: class { - func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) + func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) } diff --git a/Frameworks/Account/Feedly/Services/FeedlyGetStreamIdsService.swift b/Frameworks/Account/Feedly/Services/FeedlyGetStreamIdsService.swift index 9070cd12f..c5889cbe1 100644 --- a/Frameworks/Account/Feedly/Services/FeedlyGetStreamIdsService.swift +++ b/Frameworks/Account/Feedly/Services/FeedlyGetStreamIdsService.swift @@ -9,5 +9,5 @@ import Foundation protocol FeedlyGetStreamIdsService: class { - func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result) -> ()) + func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result) -> ()) } diff --git a/Frameworks/Account/Feedly/Services/FeedlyMarkArticlesService.swift b/Frameworks/Account/Feedly/Services/FeedlyMarkArticlesService.swift index e5f367c21..6220d147c 100644 --- a/Frameworks/Account/Feedly/Services/FeedlyMarkArticlesService.swift +++ b/Frameworks/Account/Feedly/Services/FeedlyMarkArticlesService.swift @@ -31,5 +31,5 @@ enum FeedlyMarkAction: String { } protocol FeedlyMarkArticlesService: class { - func mark(_ articleIds: Set, as action: FeedlyMarkAction, completionHandler: @escaping (Result) -> ()) + func mark(_ articleIds: Set, as action: FeedlyMarkAction, completion: @escaping (Result) -> ()) } diff --git a/Frameworks/Account/LocalAccount/InitialFeedDownloader.swift b/Frameworks/Account/LocalAccount/InitialFeedDownloader.swift index 4e7ebda05..34b1ddea3 100644 --- a/Frameworks/Account/LocalAccount/InitialFeedDownloader.swift +++ b/Frameworks/Account/LocalAccount/InitialFeedDownloader.swift @@ -12,17 +12,17 @@ import RSWeb struct InitialFeedDownloader { - static func download(_ url: URL,_ completionHandler: @escaping (_ parsedFeed: ParsedFeed?) -> Void) { + static func download(_ url: URL,_ completion: @escaping (_ parsedFeed: ParsedFeed?) -> Void) { downloadUsingCache(url) { (data, response, error) in guard let data = data else { - completionHandler(nil) + completion(nil) return } let parserData = ParserData(url: url.absoluteString, data: data) FeedParser.parse(parserData) { (parsedFeed, error) in - completionHandler(parsedFeed) + completion(parsedFeed) } } } diff --git a/Frameworks/ArticlesDatabase/ArticlesDatabase.swift b/Frameworks/ArticlesDatabase/ArticlesDatabase.swift index fcc7894c1..5d3bee42a 100644 --- a/Frameworks/ArticlesDatabase/ArticlesDatabase.swift +++ b/Frameworks/ArticlesDatabase/ArticlesDatabase.swift @@ -148,8 +148,8 @@ public final class ArticlesDatabase { articlesTable.update(webFeedIDsAndItems, defaultRead, completion) } - public func ensureStatuses(_ articleIDs: Set, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completionHandler: VoidCompletionBlock? = nil) { - articlesTable.ensureStatuses(articleIDs, defaultRead, statusKey, flag, completionHandler: completionHandler) + public func ensureStatuses(_ articleIDs: Set, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completion: VoidCompletionBlock? = nil) { + articlesTable.ensureStatuses(articleIDs, defaultRead, statusKey, flag, completion: completion) } // MARK: - Status diff --git a/Frameworks/ArticlesDatabase/ArticlesTable.swift b/Frameworks/ArticlesDatabase/ArticlesTable.swift index 25e04318c..c94990191 100644 --- a/Frameworks/ArticlesDatabase/ArticlesTable.swift +++ b/Frameworks/ArticlesDatabase/ArticlesTable.swift @@ -293,9 +293,9 @@ final class ArticlesTable: DatabaseTable { } } - func ensureStatuses(_ articleIDs: Set, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completionHandler: VoidCompletionBlock? = nil) { + func ensureStatuses(_ articleIDs: Set, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completion: VoidCompletionBlock? = nil) { guard !queue.isSuspended else { - if let handler = completionHandler { + if let handler = completion { callVoidCompletionBlock(handler) } return @@ -305,7 +305,7 @@ final class ArticlesTable: DatabaseTable { let statusesDictionary = self.statusesTable.ensureStatusesForArticleIDs(articleIDs, defaultRead, database) let statuses = Set(statusesDictionary.values) self.statusesTable.mark(statuses, statusKey, flag, database) - if let handler = completionHandler { + if let handler = completion { callVoidCompletionBlock(handler) } } diff --git a/Frameworks/SyncDatabase/SyncDatabase.swift b/Frameworks/SyncDatabase/SyncDatabase.swift index 8ffad570b..8c08bda08 100644 --- a/Frameworks/SyncDatabase/SyncDatabase.swift +++ b/Frameworks/SyncDatabase/SyncDatabase.swift @@ -31,8 +31,8 @@ public struct SyncDatabase { // MARK: - API - public func insertStatuses(_ statuses: [SyncStatus], completionHandler: VoidCompletionBlock? = nil) { - syncStatusTable.insertStatuses(statuses, completionHandler: completionHandler) + public func insertStatuses(_ statuses: [SyncStatus], completion: VoidCompletionBlock? = nil) { + syncStatusTable.insertStatuses(statuses, completion: completion) } public func selectForProcessing() -> [SyncStatus] { @@ -43,12 +43,12 @@ public struct SyncDatabase { return syncStatusTable.selectPendingCount() } - public func resetSelectedForProcessing(_ articleIDs: [String], completionHandler: VoidCompletionBlock? = nil) { - syncStatusTable.resetSelectedForProcessing(articleIDs, completionHandler: completionHandler) + public func resetSelectedForProcessing(_ articleIDs: [String], completion: VoidCompletionBlock? = nil) { + syncStatusTable.resetSelectedForProcessing(articleIDs, completion: completion) } - public func deleteSelectedForProcessing(_ articleIDs: [String], completionHandler: VoidCompletionBlock? = nil) { - syncStatusTable.deleteSelectedForProcessing(articleIDs, completionHandler: completionHandler) + public func deleteSelectedForProcessing(_ articleIDs: [String], completion: VoidCompletionBlock? = nil) { + syncStatusTable.deleteSelectedForProcessing(articleIDs, completion: completion) } // MARK: - Suspend and Resume (for iOS) diff --git a/Frameworks/SyncDatabase/SyncStatusTable.swift b/Frameworks/SyncDatabase/SyncStatusTable.swift index 681b2f780..030bb54f1 100644 --- a/Frameworks/SyncDatabase/SyncStatusTable.swift +++ b/Frameworks/SyncDatabase/SyncStatusTable.swift @@ -57,10 +57,10 @@ struct SyncStatusTable: DatabaseTable { return count } - func resetSelectedForProcessing(_ articleIDs: [String], completionHandler: VoidCompletionBlock? = nil) { + func resetSelectedForProcessing(_ articleIDs: [String], completion: VoidCompletionBlock? = nil) { guard !queue.isSuspended else { - if let handler = completionHandler { - callVoidCompletionBlock(handler) + if let completion = completion { + callVoidCompletionBlock(completion) } return } @@ -69,16 +69,16 @@ struct SyncStatusTable: DatabaseTable { let placeholders = NSString.rs_SQLValueList(withPlaceholders: UInt(articleIDs.count))! let updateSQL = "update syncStatus set selected = false where articleID in \(placeholders)" database.executeUpdate(updateSQL, withArgumentsIn: parameters) - if let handler = completionHandler { - callVoidCompletionBlock(handler) + if let completion = completion { + callVoidCompletionBlock(completion) } } } - func deleteSelectedForProcessing(_ articleIDs: [String], completionHandler: VoidCompletionBlock? = nil) { + func deleteSelectedForProcessing(_ articleIDs: [String], completion: VoidCompletionBlock? = nil) { guard !queue.isSuspended else { - if let handler = completionHandler { - callVoidCompletionBlock(handler) + if let completion = completion { + callVoidCompletionBlock(completion) } return } @@ -87,24 +87,24 @@ struct SyncStatusTable: DatabaseTable { let placeholders = NSString.rs_SQLValueList(withPlaceholders: UInt(articleIDs.count))! let deleteSQL = "delete from syncStatus where articleID in \(placeholders)" database.executeUpdate(deleteSQL, withArgumentsIn: parameters) - if let handler = completionHandler { - callVoidCompletionBlock(handler) + if let completion = completion { + callVoidCompletionBlock(completion) } } } - func insertStatuses(_ statuses: [SyncStatus], completionHandler: VoidCompletionBlock? = nil) { + func insertStatuses(_ statuses: [SyncStatus], completion: VoidCompletionBlock? = nil) { guard !queue.isSuspended else { - if let handler = completionHandler { - callVoidCompletionBlock(handler) + if let completion = completion { + callVoidCompletionBlock(completion) } return } queue.runInTransaction { database in let statusArray = statuses.map { $0.databaseDictionary() } self.insertRows(statusArray, insertType: .orReplace, in: database) - if let handler = completionHandler { - callVoidCompletionBlock(handler) + if let completion = completion { + callVoidCompletionBlock(completion) } } } diff --git a/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift b/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift index 473850d01..b0e62b26e 100644 --- a/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsFeedWranglerWindowController.swift @@ -36,9 +36,9 @@ class AccountsFeedWranglerWindowController: NSWindowController { // MARK: API - func runSheetOnWindow(_ hostWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) { + func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) { self.hostWindow = hostWindow - hostWindow.beginSheet(window!, completionHandler: handler) + hostWindow.beginSheet(window!, completionHandler: completion) } // MARK: Actions diff --git a/Mac/Preferences/Accounts/AccountsFeedbinWindowController.swift b/Mac/Preferences/Accounts/AccountsFeedbinWindowController.swift index a37c923ae..e5fb0f393 100644 --- a/Mac/Preferences/Accounts/AccountsFeedbinWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsFeedbinWindowController.swift @@ -37,9 +37,9 @@ class AccountsFeedbinWindowController: NSWindowController { // MARK: API - func runSheetOnWindow(_ hostWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) { + func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) { self.hostWindow = hostWindow - hostWindow.beginSheet(window!, completionHandler: handler) + hostWindow.beginSheet(window!, completionHandler: completion) } // MARK: Actions diff --git a/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift b/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift index 37947ca6b..80aa69c7c 100644 --- a/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift @@ -53,9 +53,9 @@ class AccountsReaderAPIWindowController: NSWindowController { // MARK: API - func runSheetOnWindow(_ hostWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) { + func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) { self.hostWindow = hostWindow - hostWindow.beginSheet(window!, completionHandler: handler) + hostWindow.beginSheet(window!, completionHandler: completion) } // MARK: Actions diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 98262460b..ccbc199dd 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -237,25 +237,25 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { // Set up the delete action let deleteTitle = NSLocalizedString("Delete", comment: "Delete") - let deleteAction = UIContextualAction(style: .normal, title: deleteTitle) { [weak self] (action, view, completionHandler) in + let deleteAction = UIContextualAction(style: .normal, title: deleteTitle) { [weak self] (action, view, completion) in self?.delete(indexPath: indexPath) - completionHandler(true) + completion(true) } deleteAction.backgroundColor = UIColor.systemRed actions.append(deleteAction) // Set up the rename action let renameTitle = NSLocalizedString("Rename", comment: "Rename") - let renameAction = UIContextualAction(style: .normal, title: renameTitle) { [weak self] (action, view, completionHandler) in + let renameAction = UIContextualAction(style: .normal, title: renameTitle) { [weak self] (action, view, completion) in self?.rename(indexPath: indexPath) - completionHandler(true) + completion(true) } renameAction.backgroundColor = UIColor.systemOrange actions.append(renameAction) if let webFeed = dataSource.itemIdentifier(for: indexPath)?.representedObject as? WebFeed { let moreTitle = NSLocalizedString("More", comment: "More") - let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completionHandler) in + let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completion) in if let self = self { @@ -265,25 +265,25 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { popoverController.sourceRect = CGRect(x: view.frame.size.width/2, y: view.frame.size.height/2, width: 1, height: 1) } - if let action = self.getInfoAlertAction(indexPath: indexPath, completionHandler: completionHandler) { + if let action = self.getInfoAlertAction(indexPath: indexPath, completion: completion) { alert.addAction(action) } - if let action = self.homePageAlertAction(indexPath: indexPath, completionHandler: completionHandler) { + if let action = self.homePageAlertAction(indexPath: indexPath, completion: completion) { alert.addAction(action) } - if let action = self.copyFeedPageAlertAction(indexPath: indexPath, completionHandler: completionHandler) { + if let action = self.copyFeedPageAlertAction(indexPath: indexPath, completion: completion) { alert.addAction(action) } - if let action = self.copyHomePageAlertAction(indexPath: indexPath, completionHandler: completionHandler) { + if let action = self.copyHomePageAlertAction(indexPath: indexPath, completion: completion) { alert.addAction(action) } let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel") alert.addAction(UIAlertAction(title: cancelTitle, style: .cancel) { _ in - completionHandler(true) + completion(true) }) self.present(alert, animated: true) @@ -887,7 +887,7 @@ private extension MasterFeedViewController { return action } - func homePageAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func homePageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard coordinator.homePageURLForFeed(indexPath) != nil else { return nil } @@ -895,7 +895,7 @@ private extension MasterFeedViewController { let title = NSLocalizedString("Open Home Page", comment: "Open Home Page") let action = UIAlertAction(title: title, style: .default) { [weak self] action in self?.coordinator.showBrowserForFeed(indexPath) - completionHandler(true) + completion(true) } return action } @@ -914,7 +914,7 @@ private extension MasterFeedViewController { return action } - func copyFeedPageAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func copyFeedPageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let node = dataSource.itemIdentifier(for: indexPath), let feed = node.representedObject as? WebFeed, let url = URL(string: feed.url) else { @@ -924,7 +924,7 @@ private extension MasterFeedViewController { let title = NSLocalizedString("Copy Feed URL", comment: "Copy Feed URL") let action = UIAlertAction(title: title, style: .default) { action in UIPasteboard.general.url = url - completionHandler(true) + completion(true) } return action } @@ -944,7 +944,7 @@ private extension MasterFeedViewController { return action } - func copyHomePageAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func copyHomePageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let node = dataSource.itemIdentifier(for: indexPath), let feed = node.representedObject as? WebFeed, let homePageURL = feed.homePageURL, @@ -955,7 +955,7 @@ private extension MasterFeedViewController { let title = NSLocalizedString("Copy Home Page URL", comment: "Copy Home Page URL") let action = UIAlertAction(title: title, style: .default) { action in UIPasteboard.general.url = url - completionHandler(true) + completion(true) } return action } @@ -1005,7 +1005,7 @@ private extension MasterFeedViewController { return action } - func getInfoAlertAction(indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func getInfoAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let node = dataSource.itemIdentifier(for: indexPath), let feed = node.representedObject as? WebFeed else { return nil } @@ -1013,7 +1013,7 @@ private extension MasterFeedViewController { let title = NSLocalizedString("Get Info", comment: "Get Info") let action = UIAlertAction(title: title, style: .default) { [weak self] action in self?.coordinator.showFeedInspector(for: feed) - completionHandler(true) + completion(true) } return action } diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index a8adc7daf..bd45ae9b3 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -203,9 +203,9 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner NSLocalizedString("Unread", comment: "Unread") : NSLocalizedString("Read", comment: "Read") - let readAction = UIContextualAction(style: .normal, title: readTitle) { [weak self] (action, view, completionHandler) in + let readAction = UIContextualAction(style: .normal, title: readTitle) { [weak self] (action, view, completion) in self?.coordinator.toggleRead(article) - completionHandler(true) + completion(true) } readAction.image = article.status.read ? AppAssets.circleClosedImage : AppAssets.circleOpenImage @@ -223,9 +223,9 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner NSLocalizedString("Unstar", comment: "Unstar") : NSLocalizedString("Star", comment: "Star") - let starAction = UIContextualAction(style: .normal, title: starTitle) { [weak self] (action, view, completionHandler) in + let starAction = UIContextualAction(style: .normal, title: starTitle) { [weak self] (action, view, completion) in self?.coordinator.toggleStar(article) - completionHandler(true) + completion(true) } starAction.image = article.status.starred ? AppAssets.starOpenImage : AppAssets.starClosedImage @@ -233,7 +233,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner // Set up the read action let moreTitle = NSLocalizedString("More", comment: "More") - let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completionHandler) in + let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completion) in if let self = self { @@ -243,27 +243,27 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner popoverController.sourceRect = CGRect(x: view.frame.size.width/2, y: view.frame.size.height/2, width: 1, height: 1) } - alert.addAction(self.markOlderAsReadAlertAction(article, completionHandler: completionHandler)) + alert.addAction(self.markOlderAsReadAlertAction(article, completion: completion)) - if let action = self.discloseFeedAlertAction(article, completionHandler: completionHandler) { + if let action = self.discloseFeedAlertAction(article, completion: completion) { alert.addAction(action) } - if let action = self.markAllInFeedAsReadAlertAction(article, completionHandler: completionHandler) { + if let action = self.markAllInFeedAsReadAlertAction(article, completion: completion) { alert.addAction(action) } - if let action = self.openInBrowserAlertAction(article, completionHandler: completionHandler) { + if let action = self.openInBrowserAlertAction(article, completion: completion) { alert.addAction(action) } - if let action = self.shareAlertAction(article, indexPath: indexPath, completionHandler: completionHandler) { + if let action = self.shareAlertAction(article, indexPath: indexPath, completion: completion) { alert.addAction(action) } let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel") alert.addAction(UIAlertAction(title: cancelTitle, style: .cancel) { _ in - completionHandler(true) + completion(true) }) self.present(alert, animated: true) @@ -643,11 +643,11 @@ private extension MasterTimelineViewController { return action } - func markOlderAsReadAlertAction(_ article: Article, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction { + func markOlderAsReadAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction { let title = NSLocalizedString("Mark Older as Read", comment: "Mark Older as Read") let action = UIAlertAction(title: title, style: .default) { [weak self] action in self?.coordinator.markAsReadOlderArticlesInTimeline(article) - completionHandler(true) + completion(true) } return action } @@ -662,13 +662,13 @@ private extension MasterTimelineViewController { return action } - func discloseFeedAlertAction(_ article: Article, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func discloseFeedAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let webFeed = article.webFeed else { return nil } let title = NSLocalizedString("Go to Feed", comment: "Go to Feed") let action = UIAlertAction(title: title, style: .default) { [weak self] action in self?.coordinator.discloseFeed(webFeed, animated: true) - completionHandler(true) + completion(true) } return action } @@ -690,7 +690,7 @@ private extension MasterTimelineViewController { return action } - func markAllInFeedAsReadAlertAction(_ article: Article, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func markAllInFeedAsReadAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let webFeed = article.webFeed else { return nil } let articles = Array(webFeed.fetchArticles()) @@ -703,7 +703,7 @@ private extension MasterTimelineViewController { let action = UIAlertAction(title: title, style: .default) { [weak self] action in self?.coordinator.markAllAsRead(articles) - completionHandler(true) + completion(true) } return action } @@ -719,14 +719,14 @@ private extension MasterTimelineViewController { return action } - func openInBrowserAlertAction(_ article: Article, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func openInBrowserAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let preferredLink = article.preferredLink, let _ = URL(string: preferredLink) else { return nil } let title = NSLocalizedString("Open in Browser", comment: "Open in Browser") let action = UIAlertAction(title: title, style: .default) { [weak self] action in self?.coordinator.showBrowserForArticle(article) - completionHandler(true) + completion(true) } return action } @@ -755,14 +755,14 @@ private extension MasterTimelineViewController { return action } - func shareAlertAction(_ article: Article, indexPath: IndexPath, completionHandler: @escaping (Bool) -> Void) -> UIAlertAction? { + func shareAlertAction(_ article: Article, indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? { guard let preferredLink = article.preferredLink, let url = URL(string: preferredLink) else { return nil } let title = NSLocalizedString("Share", comment: "Share") let action = UIAlertAction(title: title, style: .default) { [weak self] action in - completionHandler(true) + completion(true) self?.shareDialogForTableCell(indexPath: indexPath, url: url, title: article.title) } return action