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
}
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)
InitialFeedDownloader.download(url) { [weak self] parsedFeed in
if let parsedFeed = parsedFeed {

View File

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