mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Start work on adding feeds and folders.
This commit is contained in:
parent
21080a97fc
commit
2978d4420b
@ -10,14 +10,14 @@ import Foundation
|
||||
import Data
|
||||
import Account
|
||||
|
||||
private typealias DiskFeedDictionary = [String: String]
|
||||
typealias DiskFeedDictionary = [String: String]
|
||||
|
||||
struct DefaultFeedsImporter {
|
||||
|
||||
static func importIfNeeded(_ firstRun: Bool, account: Account) {
|
||||
|
||||
if shouldImportDefaultFeeds(firstRun) {
|
||||
FeedsImporter.import(defaultFeeds(), account: account)
|
||||
FeedsImporter.importFeeds(defaultFeeds(), account: account)
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,10 +44,10 @@ struct DefaultFeedsImporter {
|
||||
|
||||
struct FeedsImporter {
|
||||
|
||||
func import(_ feedDictionaries: [DiskFeedDictionary], account: Account) {
|
||||
func importFeeds(_ feedDictionaries: [DiskFeedDictionary], account: Account) {
|
||||
|
||||
let feeds = feeds(with: feedDictionaries)
|
||||
feeds.forEach { let _ = account.addItem($0) }
|
||||
let feedsToImport = feeds(with: feedDictionaries)
|
||||
feedsToImport.forEach(account.addItem)
|
||||
}
|
||||
|
||||
private func feeds(with feedDictionaries: [DiskFeedDictionary]) -> Set<Feed> {
|
||||
|
@ -228,7 +228,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
||||
guard let articles = note.appInfo?.articles else {
|
||||
return
|
||||
}
|
||||
reloadCellsForArticles(articles)
|
||||
reloadCellsForArticles(Array(articles))
|
||||
}
|
||||
|
||||
func fontSizeInDefaultsDidChange() {
|
||||
@ -312,7 +312,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
||||
return nil
|
||||
}
|
||||
|
||||
private func reloadCellsForArticles(_ articles: Set<Article>) {
|
||||
private func reloadCellsForArticles(_ articles: [Article]) {
|
||||
|
||||
let indexes = indexesForArticles(articles)
|
||||
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
||||
@ -320,7 +320,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
||||
|
||||
// MARK: Articles
|
||||
|
||||
private func indexesForArticles(_ articles: Set<Article>) -> IndexSet {
|
||||
private func indexesForArticles(_ articles: [Article]) -> IndexSet {
|
||||
|
||||
var indexes = IndexSet()
|
||||
|
||||
|
@ -80,6 +80,34 @@ public final class Account: DisplayNameProvider, Hashable {
|
||||
return nil //TODO
|
||||
}
|
||||
|
||||
public func canAddFeed(_ feed: Feed, to folder: Folder?) -> Bool {
|
||||
|
||||
// If folder is nil, then it should go at the top level.
|
||||
// The same feed in multiple folders is allowed.
|
||||
// But the same feed can’t appear twice in the same folder
|
||||
// (or at the top level).
|
||||
|
||||
return true // TODO
|
||||
}
|
||||
|
||||
public func addFeed(_ feed: Feed, to folder: Folder?) -> Bool {
|
||||
|
||||
// Return false if it couldn’t be added.
|
||||
// If it already existed in that folder, return true.
|
||||
|
||||
return true // TODO
|
||||
}
|
||||
|
||||
public func canAddFolder(_ folder: Folder, to folder: Folder?) -> Bool {
|
||||
|
||||
return false // TODO
|
||||
}
|
||||
|
||||
public func addFolder(_ folder: Folder, to folder: Folder?) -> Bool {
|
||||
|
||||
return false // TODO
|
||||
}
|
||||
|
||||
public func importOPML(_ opmlDocument: RSOPMLDocument) {
|
||||
|
||||
// TODO
|
||||
|
@ -21,13 +21,4 @@ public extension Feed {
|
||||
return accountWithID(accountID)
|
||||
}
|
||||
}
|
||||
|
||||
struct DictionaryKey {
|
||||
static let
|
||||
}
|
||||
|
||||
init?(accountID: String, feedDictionary: FeedDictionary) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
import RSCore
|
||||
import RSWeb
|
||||
|
||||
public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
||||
public final class Feed: DisplayNameProvider, UnreadCountProvider, Codable, Hashable {
|
||||
|
||||
public let accountID: String
|
||||
public let url: String
|
||||
|
Loading…
x
Reference in New Issue
Block a user