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 Data
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
private typealias DiskFeedDictionary = [String: String]
|
typealias DiskFeedDictionary = [String: String]
|
||||||
|
|
||||||
struct DefaultFeedsImporter {
|
struct DefaultFeedsImporter {
|
||||||
|
|
||||||
static func importIfNeeded(_ firstRun: Bool, account: Account) {
|
static func importIfNeeded(_ firstRun: Bool, account: Account) {
|
||||||
|
|
||||||
if shouldImportDefaultFeeds(firstRun) {
|
if shouldImportDefaultFeeds(firstRun) {
|
||||||
FeedsImporter.import(defaultFeeds(), account: account)
|
FeedsImporter.importFeeds(defaultFeeds(), account: account)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ struct DefaultFeedsImporter {
|
|||||||
|
|
||||||
struct FeedsImporter {
|
struct FeedsImporter {
|
||||||
|
|
||||||
func import(_ feedDictionaries: [DiskFeedDictionary], account: Account) {
|
func importFeeds(_ feedDictionaries: [DiskFeedDictionary], account: Account) {
|
||||||
|
|
||||||
let feeds = feeds(with: feedDictionaries)
|
let feedsToImport = feeds(with: feedDictionaries)
|
||||||
feeds.forEach { let _ = account.addItem($0) }
|
feedsToImport.forEach(account.addItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func feeds(with feedDictionaries: [DiskFeedDictionary]) -> Set<Feed> {
|
private func feeds(with feedDictionaries: [DiskFeedDictionary]) -> Set<Feed> {
|
||||||
|
@ -228,7 +228,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
|||||||
guard let articles = note.appInfo?.articles else {
|
guard let articles = note.appInfo?.articles else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reloadCellsForArticles(articles)
|
reloadCellsForArticles(Array(articles))
|
||||||
}
|
}
|
||||||
|
|
||||||
func fontSizeInDefaultsDidChange() {
|
func fontSizeInDefaultsDidChange() {
|
||||||
@ -312,7 +312,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reloadCellsForArticles(_ articles: Set<Article>) {
|
private func reloadCellsForArticles(_ articles: [Article]) {
|
||||||
|
|
||||||
let indexes = indexesForArticles(articles)
|
let indexes = indexesForArticles(articles)
|
||||||
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
||||||
@ -320,7 +320,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
|||||||
|
|
||||||
// MARK: Articles
|
// MARK: Articles
|
||||||
|
|
||||||
private func indexesForArticles(_ articles: Set<Article>) -> IndexSet {
|
private func indexesForArticles(_ articles: [Article]) -> IndexSet {
|
||||||
|
|
||||||
var indexes = IndexSet()
|
var indexes = IndexSet()
|
||||||
|
|
||||||
|
@ -79,7 +79,35 @@ public final class Account: DisplayNameProvider, Hashable {
|
|||||||
|
|
||||||
return nil //TODO
|
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) {
|
public func importOPML(_ opmlDocument: RSOPMLDocument) {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -18,7 +18,7 @@ extension NSNotification.Name {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public protocol Container {
|
public protocol Container {
|
||||||
|
|
||||||
//Recursive
|
//Recursive
|
||||||
func hasAtLeastOneFeed() -> Bool
|
func hasAtLeastOneFeed() -> Bool
|
||||||
func flattenedFeeds() -> Set<Feed>
|
func flattenedFeeds() -> Set<Feed>
|
||||||
|
@ -21,13 +21,4 @@ public extension Feed {
|
|||||||
return accountWithID(accountID)
|
return accountWithID(accountID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DictionaryKey {
|
|
||||||
static let
|
|
||||||
}
|
|
||||||
|
|
||||||
init?(accountID: String, feedDictionary: FeedDictionary) {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import Foundation
|
|||||||
import RSCore
|
import RSCore
|
||||||
import RSWeb
|
import RSWeb
|
||||||
|
|
||||||
public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
public final class Feed: DisplayNameProvider, UnreadCountProvider, Codable, Hashable {
|
||||||
|
|
||||||
public let accountID: String
|
public let accountID: String
|
||||||
public let url: String
|
public let url: String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user