Continue removing old code for pre-OPML subscriptions.
This commit is contained in:
parent
8de36d8282
commit
4d727ce094
|
@ -590,16 +590,6 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
}
|
||||
|
||||
|
||||
// MARK: - Disk (Public)
|
||||
|
||||
extension Account {
|
||||
|
||||
func objects(with diskObjects: [[String: Any]]) -> [AnyObject] {
|
||||
|
||||
return diskObjects.compactMap { object(with: $0) }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - FeedMetadataDelegate
|
||||
|
||||
extension Account: FeedMetadataDelegate {
|
||||
|
@ -624,14 +614,6 @@ private extension Account {
|
|||
Account.saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
||||
}
|
||||
|
||||
func object(with diskObject: [String: Any]) -> AnyObject? {
|
||||
|
||||
if Feed.isFeedDictionary(diskObject) {
|
||||
return Feed(account: self, dictionary: diskObject)
|
||||
}
|
||||
return Folder(account: self, dictionary: diskObject)
|
||||
}
|
||||
|
||||
func pullObjectsFromDisk() {
|
||||
importFeedMetadata()
|
||||
importOPMLFile(path: opmlFilePath)
|
||||
|
|
|
@ -10,25 +10,9 @@ import Foundation
|
|||
import RSCore
|
||||
import RSWeb
|
||||
import Articles
|
||||
import RSDatabase
|
||||
|
||||
public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Hashable {
|
||||
|
||||
private struct Key {
|
||||
static let url = "url"
|
||||
static let feedID = "feedID"
|
||||
static let homePageURL = "homePageURL"
|
||||
static let iconURL = "iconURL"
|
||||
static let faviconURL = "faviconURL"
|
||||
static let name = "name"
|
||||
static let editedName = "editedName"
|
||||
static let authors = "authors"
|
||||
static let conditionalGetInfo = "conditionalGetInfo"
|
||||
static let conditionalGetLastModified = "lastModified"
|
||||
static let conditionalGetEtag = "etag"
|
||||
static let contentHash = "contentHash"
|
||||
}
|
||||
|
||||
public weak var account: Account?
|
||||
public let url: String
|
||||
public let feedID: String
|
||||
|
@ -187,25 +171,6 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
|
|||
self.feedID = feedID
|
||||
}
|
||||
|
||||
// MARK: - Disk Dictionary
|
||||
|
||||
convenience public init?(account: Account, dictionary: [String: Any]) {
|
||||
|
||||
guard let url = dictionary[Key.url] as? String else {
|
||||
return nil
|
||||
}
|
||||
let feedID = dictionary[Key.feedID] as? String ?? url
|
||||
|
||||
self.init(account: account, url: url, feedID: feedID)
|
||||
self.editedName = dictionary[Key.editedName] as? String
|
||||
self.name = dictionary[Key.name] as? String
|
||||
}
|
||||
|
||||
public static func isFeedDictionary(_ d: [String: Any]) -> Bool {
|
||||
|
||||
return d[Key.url] != nil
|
||||
}
|
||||
|
||||
// MARK: - Debug
|
||||
|
||||
public func debugDropConditionalGetInfo() {
|
||||
|
|
|
@ -12,7 +12,6 @@ import RSCore
|
|||
|
||||
public final class Folder: DisplayNameProvider, Renamable, Container, UnreadCountProvider, Hashable {
|
||||
|
||||
|
||||
public weak var account: Account?
|
||||
public var topLevelFeeds: Set<Feed> = Set<Feed>()
|
||||
public var folders: Set<Folder>? = nil // subfolders are not supported, so this is always nil
|
||||
|
@ -64,23 +63,6 @@ public final class Folder: DisplayNameProvider, Renamable, Container, UnreadCoun
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(childrenDidChange(_:)), name: .ChildrenDidChange, object: self)
|
||||
}
|
||||
|
||||
// MARK: - Disk Dictionary
|
||||
|
||||
private struct Key {
|
||||
static let name = "name"
|
||||
static let children = "children"
|
||||
}
|
||||
|
||||
convenience init?(account: Account, dictionary: [String: Any]) {
|
||||
|
||||
let name = dictionary[Key.name] as? String
|
||||
self.init(account: account, name: name)
|
||||
|
||||
if let childrenArray = dictionary[Key.children] as? [[String: Any]] {
|
||||
self.topLevelFeeds = Folder.feedsOnly(with: childrenArray, account: account)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc func unreadCountDidChange(_ note: Notification) {
|
||||
|
@ -152,36 +134,7 @@ private extension Folder {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - Disk
|
||||
|
||||
private extension Folder {
|
||||
|
||||
static func feedsOnly(with diskObjects: [[String: Any]], account: Account) -> Set<Feed> {
|
||||
|
||||
// This Folder doesn’t support subfolders, but they might exist on disk.
|
||||
// (For instance: a user might manually edit the plist to add subfolders.)
|
||||
// Create a flattened version of the feeds.
|
||||
|
||||
var feeds = Set<Feed>()
|
||||
|
||||
for diskObject in diskObjects {
|
||||
|
||||
if Feed.isFeedDictionary(diskObject) {
|
||||
if let feed = Feed(account: account, dictionary: diskObject) {
|
||||
feeds.insert(feed)
|
||||
}
|
||||
}
|
||||
else { // Folder
|
||||
if let subFolderChildren = diskObject[Key.children] as? [[String: Any]] {
|
||||
let subFolderFeeds = feedsOnly(with: subFolderChildren, account: account)
|
||||
feeds.formUnion(subFolderFeeds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return feeds
|
||||
}
|
||||
}
|
||||
// MARK: - OPMLRepresentable
|
||||
|
||||
extension Folder: OPMLRepresentable {
|
||||
|
||||
|
|
Loading…
Reference in New Issue