Update iOS to work with latest from the Accounts framework

This commit is contained in:
Maurice Parker 2019-05-09 17:30:36 -05:00
parent 23b43ecc07
commit 2401c96c99
2 changed files with 35 additions and 15 deletions

View File

@ -90,7 +90,7 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh
delegate?.processingDidBegin()
account!.createFeed(with: nil, url: url.absoluteString) { [weak self] result in
account!.createFeed(url: url.absoluteString) { [weak self] result in
switch result {
case .success(let createFeedResult):
@ -176,13 +176,29 @@ private extension AddFeedViewController {
}
}
// TODO: make this async and add to above code
account.addFeed(feed, to: folder)
// Move this into the mess above
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
delegate?.processingDidEnd()
if let folder = folder {
folder.addFeed(feed) { [weak self] result in
switch result {
case .success:
self?.delegate?.processingDidEnd()
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
case .failure(let error):
self?.delegate?.processingDidEnd()
self?.presentError(error)
}
}
} else {
account.addFeed(feed) { [weak self] result in
switch result {
case .success:
self?.delegate?.processingDidEnd()
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
case .failure(let error):
self?.delegate?.processingDidEnd()
self?.presentError(error)
}
}
}
}

View File

@ -362,19 +362,23 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn
}()
// Move the Feed
let account = accountForNode(destNode)
let sourceContainer = sourceNode.parent?.representedObject as? Container
let destinationFolder = destParentNode?.representedObject as? Folder
sourceContainer?.deleteFeed(feed) { [weak self] result in
let source = sourceNode.parent?.representedObject as? Container
let destination = destParentNode?.representedObject as? Container
source?.removeFeed(feed) { [weak self] result in
switch result {
case .success:
break
destination?.addFeed(feed) { result in
switch result {
case .success:
break
case .failure(let error):
self?.presentError(error)
}
}
case .failure(let error):
self?.presentError(error)
}
}
account?.addFeed(feed, to: destinationFolder)
account?.structureDidChange()
}