Rename occurrences of completionHandler to completion.
This commit is contained in:
parent
d870c4ffb3
commit
43bf65b7a6
|
@ -351,7 +351,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
client: OAuthAuthorizationClient,
|
||||
accountType: AccountType,
|
||||
transport: Transport = URLSession.webserviceTransport(),
|
||||
completionHandler: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
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, Error>) -> Void) {
|
||||
|
@ -754,12 +754,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
return updatedArticles
|
||||
}
|
||||
|
||||
func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completionHandler: VoidCompletionBlock? = nil) {
|
||||
func ensureStatuses(_ articleIDs: Set<String>, _ 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<ArticleStatus> as first parameter.
|
||||
func fetchStatuses(articleIDs: Set<String>, createIfNeeded: Bool, completionHandler: @escaping (Set<ArticleStatus>?) -> Void) {
|
||||
database.fetchStatuses(articleIDs: articleIDs, createIfNeeded: createIfNeeded, callback: completionHandler)
|
||||
func fetchStatuses(articleIDs: Set<String>, createIfNeeded: Bool, completion: @escaping (Set<ArticleStatus>?) -> 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.
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,13 @@ class FeedlyLogoutOperationTests: XCTestCase {
|
|||
var mockResult: Result<Void, Error>?
|
||||
var logoutExpectation: XCTestExpectation?
|
||||
|
||||
func logout(completionHandler: @escaping (Result<Void, Error>) -> ()) {
|
||||
func logout(completion: @escaping (Result<Void, 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.logoutExpectation?.fulfill()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class FeedlyRefreshAccessTokenOperationTests: XCTestCase {
|
|||
var refreshAccessTokenExpectation: XCTestExpectation?
|
||||
var parameterTester: ((String, OAuthAuthorizationClient) -> ())?
|
||||
|
||||
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completionHandler: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<FeedlyStream, Error>) -> ()) {
|
||||
func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> ()) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<FeedlyStreamIds, Error>) -> ()) {
|
||||
func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> ()) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<FeedlyStream, Error>) -> ()) {
|
||||
func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> ()) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<FeedlyStreamIds, Error>) -> ()) {
|
||||
func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> ()) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ class TestMarkArticlesService: FeedlyMarkArticlesService {
|
|||
var parameterTester: ((Set<String>, FeedlyMarkAction) -> ())?
|
||||
var mockResult: Result<Void, Error> = .success(())
|
||||
|
||||
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completionHandler: @escaping (Result<Void, Error>) -> ()) {
|
||||
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, Error>) -> ()) {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.parameterTester?(articleIds, action)
|
||||
completionHandler(self.mockResult)
|
||||
completion(self.mockResult)
|
||||
self.didMarkExpectation?.fulfill()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,16 +69,16 @@ final class FeedlyAPICaller {
|
|||
isSuspended = false
|
||||
}
|
||||
|
||||
func importOpml(_ opmlData: Data, completionHandler: @escaping (Result<Void, Error>) -> ()) {
|
||||
func importOpml(_ opmlData: Data, completion: @escaping (Result<Void, 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
|
||||
|
@ -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<FeedlyCollection, Error>) -> ()) {
|
||||
func createCollection(named label: String, 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
|
||||
|
@ -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<FeedlyCollection, Error>) -> ()) {
|
||||
func renameCollection(with id: String, to name: String, 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
|
||||
|
@ -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<Void, Error>) -> ()) {
|
||||
func deleteCollection(with id: String, completion: @escaping (Result<Void, 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(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<Void, Error>) -> ()) {
|
||||
func removeFeed(_ feedId: String, fromCollectionWith collectionId: String, completion: @escaping (Result<Void, 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 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<FeedlyOAuthAccessTokenResponse, Error>) -> ()) {
|
||||
func requestAccessToken(_ authorizationRequest: OAuthAccessTokenRequest, completion: @escaping (Result<FeedlyOAuthAccessTokenResponse, Error>) -> ()) {
|
||||
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<FeedlyOAuthAccessTokenResponse, Error>) -> ()) {
|
||||
func refreshAccessToken(_ refreshRequest: OAuthRefreshAccessTokenRequest, completion: @escaping (Result<FeedlyOAuthAccessTokenResponse, Error>) -> ()) {
|
||||
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<FeedlyStream, Error>) -> ()) {
|
||||
func getStreamContents(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, 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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<FeedlyStreamIds, Error>) -> ()) {
|
||||
func getStreamIds(for resource: FeedlyResourceId, continuation: String? = nil, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, 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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<String>, completionHandler: @escaping (Result<[FeedlyEntry], Error>) -> ()) {
|
||||
func getEntries(for ids: Set<String>, 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<String>, as action: FeedlyMarkAction, completionHandler: @escaping (Result<Void, Error>) -> ()) {
|
||||
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, 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
|
||||
|
@ -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<FeedlyFeedsSearchResponse, Error>) -> ()) {
|
||||
func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> ()) {
|
||||
|
||||
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<Void, Error>) -> ()) {
|
||||
func logout(completion: @escaping (Result<Void, 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
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
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<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ()) {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<AccessTokenResponse, Error>) -> ())
|
||||
/// - 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<AccessTokenResponse, Error>) -> ())
|
||||
}
|
||||
|
||||
/// Implemented by concrete types to perform the actual request.
|
||||
protocol OAuthAccessTokenRefreshing: class {
|
||||
|
||||
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completionHandler: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ())
|
||||
func refreshAccessToken(with refreshToken: String, client: OAuthAuthorizationClient, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -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<AccessTokenResponse, Error>) -> ())
|
||||
/// - 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<AccessTokenResponse, Error>) -> ())
|
||||
}
|
||||
|
||||
protocol OAuthAuthorizationGranting: AccountDelegate {
|
||||
|
||||
static func oauthAuthorizationCodeGrantRequest() -> URLRequest
|
||||
|
||||
static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completionHandler: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ())
|
||||
static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse, transport: Transport, completion: @escaping (Result<OAuthAuthorizationGrant, Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -10,7 +10,7 @@ import Foundation
|
|||
import os.log
|
||||
|
||||
protocol FeedlyLogoutService {
|
||||
func logout(completionHandler: @escaping (Result<Void, Error>) -> ())
|
||||
func logout(completion: @escaping (Result<Void, Error>) -> ())
|
||||
}
|
||||
|
||||
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<Void, Error>) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import Foundation
|
||||
|
||||
protocol FeedlySearchService: class {
|
||||
func getFeeds(for query: String, count: Int, locale: String, completionHandler: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> ())
|
||||
func getFeeds(for query: String, count: Int, locale: String, completion: @escaping (Result<FeedlyFeedsSearchResponse, Error>) -> ())
|
||||
}
|
||||
|
||||
protocol FeedlySearchOperationDelegate: class {
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
import Foundation
|
||||
|
||||
protocol FeedlyGetCollectionsService: class {
|
||||
func getCollections(completionHandler: @escaping (Result<[FeedlyCollection], Error>) -> ())
|
||||
func getCollections(completion: @escaping (Result<[FeedlyCollection], Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
import Foundation
|
||||
|
||||
protocol FeedlyGetEntriesService: class {
|
||||
func getEntries(for ids: Set<String>, completionHandler: @escaping (Result<[FeedlyEntry], Error>) -> ())
|
||||
func getEntries(for ids: Set<String>, completion: @escaping (Result<[FeedlyEntry], Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
import Foundation
|
||||
|
||||
protocol FeedlyGetStreamContentsService: class {
|
||||
func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result<FeedlyStream, Error>) -> ())
|
||||
func getStreamContents(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStream, Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
import Foundation
|
||||
|
||||
protocol FeedlyGetStreamIdsService: class {
|
||||
func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completionHandler: @escaping (Result<FeedlyStreamIds, Error>) -> ())
|
||||
func getStreamIds(for resource: FeedlyResourceId, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIds, Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -31,5 +31,5 @@ enum FeedlyMarkAction: String {
|
|||
}
|
||||
|
||||
protocol FeedlyMarkArticlesService: class {
|
||||
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completionHandler: @escaping (Result<Void, Error>) -> ())
|
||||
func mark(_ articleIds: Set<String>, as action: FeedlyMarkAction, completion: @escaping (Result<Void, Error>) -> ())
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,8 +148,8 @@ public final class ArticlesDatabase {
|
|||
articlesTable.update(webFeedIDsAndItems, defaultRead, completion)
|
||||
}
|
||||
|
||||
public func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completionHandler: VoidCompletionBlock? = nil) {
|
||||
articlesTable.ensureStatuses(articleIDs, defaultRead, statusKey, flag, completionHandler: completionHandler)
|
||||
public func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completion: VoidCompletionBlock? = nil) {
|
||||
articlesTable.ensureStatuses(articleIDs, defaultRead, statusKey, flag, completion: completion)
|
||||
}
|
||||
|
||||
// MARK: - Status
|
||||
|
|
|
@ -293,9 +293,9 @@ final class ArticlesTable: DatabaseTable {
|
|||
}
|
||||
}
|
||||
|
||||
func ensureStatuses(_ articleIDs: Set<String>, _ defaultRead: Bool, _ statusKey: ArticleStatus.Key, _ flag: Bool, completionHandler: VoidCompletionBlock? = nil) {
|
||||
func ensureStatuses(_ articleIDs: Set<String>, _ 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue