Add createFeed method.

This commit is contained in:
Brent Simmons 2017-09-30 16:56:48 -07:00
parent 1f677ca600
commit a910841c65
2 changed files with 17 additions and 3 deletions

View File

@ -60,9 +60,7 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
closeAddFeedSheet(NSApplication.ModalResponse.OK)
assert(folder.account != nil, "Folder must have an account.")
let account = folder.account ?? AccountManager.shared.localAccount
let account = folder.account
if account.hasFeed(withURL: url.absoluteString) {
showAlreadySubscribedError(url.absoluteString, folder)
return

View File

@ -106,6 +106,22 @@ public final class Account: DisplayNameProvider, Hashable {
return true // TODO
}
public func createFeed(with name: String, userEnteredName: String, url: String) -> Feed {
// For syncing, this may need to be an async method with a callback,
// since it will likely need to call the server.
if let feed = existingFeed(withURL: url) {
feed.editedName = userEnteredName
return feed
}
let feed = Feed(accountID: accountID, url: url, feedID: url)
feed.name = name
feed.editedName = userEnteredName
return feed
}
public func canAddFolder(_ folder: Folder, to containingFolder: Folder?) -> Bool {
return false // TODO