Convert createFeed to async await.

This commit is contained in:
Brent Simmons
2024-04-02 20:46:28 -07:00
parent 323d0404f2
commit 8fa2d9bda4
15 changed files with 161 additions and 107 deletions

View File

@@ -117,23 +117,21 @@ class AddFeedViewController: UITableViewController {
BatchUpdate.shared.start()
account!.createFeed(url: url.absoluteString, name: feedName, container: container, validateFeed: true) { result in
BatchUpdate.shared.end()
switch result {
case .success(let feed):
Task { @MainActor in
do {
let feed = try await account!.createFeed(url: url.absoluteString, name: feedName, container: container, validateFeed: true)
self.dismiss(animated: true)
NotificationCenter.default.post(name: .UserDidAddFeed, object: self, userInfo: [UserInfoKey.feed: feed])
case .failure(let error):
} catch {
self.addButton.isEnabled = true
self.activityIndicator.isHidden = true
self.activityIndicator.stopAnimating()
self.presentError(error)
}
BatchUpdate.shared.end()
}
}
@objc func textDidChange(_ note: Notification) {