From 8014b568462a036626fccbff542533bc73ec2e67 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 4 Nov 2017 15:36:33 -0700 Subject: [PATCH] Make FeedListFeed and FeedListFolder structs. --- Evergreen/FeedList/FeedListFeed.swift | 4 ++-- Evergreen/FeedList/FeedListFolder.swift | 4 ++-- Evergreen/FeedList/FeedListTreeControllerDelegate.swift | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Evergreen/FeedList/FeedListFeed.swift b/Evergreen/FeedList/FeedListFeed.swift index 8a0b658ad..5ffdc8d2e 100644 --- a/Evergreen/FeedList/FeedListFeed.swift +++ b/Evergreen/FeedList/FeedListFeed.swift @@ -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]! diff --git a/Evergreen/FeedList/FeedListFolder.swift b/Evergreen/FeedList/FeedListFolder.swift index 2f791b872..02cdd4c1a 100644 --- a/Evergreen/FeedList/FeedListFolder.swift +++ b/Evergreen/FeedList/FeedListFolder.swift @@ -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 @@ -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 } } diff --git a/Evergreen/FeedList/FeedListTreeControllerDelegate.swift b/Evergreen/FeedList/FeedListTreeControllerDelegate.swift index f04ae16da..f4d978125 100644 --- a/Evergreen/FeedList/FeedListTreeControllerDelegate.swift +++ b/Evergreen/FeedList/FeedListTreeControllerDelegate.swift @@ -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)