Add already subscribed error to LocalAccountDelegate and updated iOS to work with latest Account API

This commit is contained in:
Maurice Parker 2019-05-10 10:22:28 -05:00
parent fe70723eb4
commit fd8a973084
2 changed files with 15 additions and 13 deletions

View File

@ -152,6 +152,11 @@ extension LocalAccountDelegate: FeedFinderDelegate {
return return
} }
if account.hasFeed(withURL: bestFeedSpecifier.urlString) {
createFeedCompletion!(.failure(AccountError.createErrorAlreadySubscribed))
return
}
let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil) let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil)
InitialFeedDownloader.download(url) { [weak self] parsedFeed in InitialFeedDownloader.download(url) { [weak self] parsedFeed in
if let parsedFeed = parsedFeed { if let parsedFeed = parsedFeed {

View File

@ -93,24 +93,21 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh
account!.createFeed(url: url.absoluteString) { [weak self] result in account!.createFeed(url: url.absoluteString) { [weak self] result in
switch result { switch result {
case .success(let createFeedResult): case .success(let feed):
switch createFeedResult {
case .created(let feed):
self?.processFeed(feed, account: account!, folder: folder, url: url, title: title) self?.processFeed(feed, account: account!, folder: folder, url: url, title: title)
case .multipleChoice(let feedChoices): case .failure(let error):
print() switch error {
self?.delegate?.processingDidCancel() case AccountError.createErrorAlreadySubscribed:
case .alreadySubscribed:
self?.showAlreadySubscribedError() self?.showAlreadySubscribedError()
self?.delegate?.processingDidCancel() self?.delegate?.processingDidCancel()
case .notFound: case AccountError.createErrorNotFound:
self?.showNoFeedsErrorMessage() self?.showNoFeedsErrorMessage()
self?.delegate?.processingDidCancel() self?.delegate?.processingDidCancel()
} default:
case .failure(let error):
self?.presentError(error) self?.presentError(error)
self?.delegate?.processingDidCancel() self?.delegate?.processingDidCancel()
} }
}
} }