Make FeedListFeed and FeedListFolder structs.

This commit is contained in:
Brent Simmons 2017-11-04 15:36:33 -07:00
parent c08bbaa970
commit 8014b56846
3 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@
import Foundation
import RSCore
final class FeedListFeed: Hashable, DisplayNameProvider {
struct FeedListFeed: Hashable, DisplayNameProvider {
let name: String
let url: String
@ -37,7 +37,7 @@ final class FeedListFeed: Hashable, DisplayNameProvider {
static let homePageURL = "homePageURL"
}
convenience init(dictionary: [String: String]) {
init(dictionary: [String: String]) {
let name = (dictionary[Key.name] ?? dictionary[Key.editedName])!
let url = dictionary[Key.url]!

View File

@ -10,7 +10,7 @@ import Foundation
import RSCore
import Data
final class FeedListFolder: Hashable, DisplayNameProvider {
struct FeedListFolder: Hashable, DisplayNameProvider {
let name: String
let feeds: Set<FeedListFeed>
@ -31,6 +31,6 @@ final class FeedListFolder: Hashable, DisplayNameProvider {
static func ==(lhs: FeedListFolder, rhs: FeedListFolder) -> Bool {
return lhs === rhs
return lhs.name == rhs.name && lhs.feeds == rhs.feeds
}
}

View File

@ -48,7 +48,7 @@ private extension FeedListTreeControllerDelegate {
func childNodesForRootNode(_ rootNode: Node) -> [Node]? {
let children = Array(topLevelFeeds) as [AnyObject] + Array(folders) as [AnyObject]
let children = (Array(topLevelFeeds) as [AnyHashable]) + (Array(folders) as [AnyHashable])
return childNodesForContainerNode(rootNode, children)
}
@ -58,18 +58,18 @@ private extension FeedListTreeControllerDelegate {
return childNodesForContainerNode(folderNode, Array(folder.feeds))
}
func childNodesForContainerNode(_ containerNode: Node, _ children: [AnyObject]) -> [Node]? {
func childNodesForContainerNode(_ containerNode: Node, _ children: [AnyHashable]) -> [Node]? {
let nodes = unsortedNodes(parent: containerNode, children: children)
return Node.nodesSortedAlphabeticallyWithFoldersAtEnd(nodes)
}
func unsortedNodes(parent: Node, children: [AnyObject]) -> [Node] {
func unsortedNodes(parent: Node, children: [AnyHashable]) -> [Node] {
return children.map{ createNode(child: $0, parent: parent) }
}
func createNode(child: AnyObject, parent: Node) -> Node {
func createNode(child: AnyHashable, parent: Node) -> Node {
if let feed = child as? FeedListFeed {
return createNode(feed: feed, parent: parent)