From 3d4523149462a472105eb6fc111313acdd809b39 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 16 Sep 2018 13:04:42 -0700 Subject: [PATCH] =?UTF-8?q?Stop=20using=20urlToFeedDictionary.=20Feeds=20d?= =?UTF-8?q?on=E2=80=99t=20have=20to=20be=20uniqued.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Account/Account.swift | 43 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 6ee00990a..facd4e9b1 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -49,7 +49,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, public let type: AccountType public var nameForDisplay = "" public var children = [AnyObject]() - var urlToFeedDictionary = [String: Feed]() +// var urlToFeedDictionary = [String: Feed]() var idToFeedDictionary = [String: Feed]() let settingsFile: String let dataFolder: String @@ -240,21 +240,21 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, // If it already existed in that folder, return true. var didAddFeed = false - let uniquedFeed = existingFeed(with: feed.feedID) ?? feed - +// let uniquedFeed = existingFeed(with: feed.feedID) ?? feed + if let folder = folder { - didAddFeed = folder.addFeed(uniquedFeed) + didAddFeed = folder.addFeed(feed) } else { - if !topLevelObjectsContainsFeed(uniquedFeed) { - children += [uniquedFeed] + if !topLevelObjectsContainsFeed(feed) { + children += [feed] postChildrenDidChangeNotification() } didAddFeed = true } if didAddFeed { - addToFeedDictionaries(uniquedFeed) + addToFeedDictionaries(feed) dirty = true } @@ -266,17 +266,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, // For syncing, this may need to be an async method with a callback, // since it will likely need to call the server. - if let feed = existingFeed(withURL: url) { - if let editedName = editedName { - feed.editedName = editedName - } - return feed - } - let feed = Feed(account: self, url: url, feedID: url) - feed.name = name - feed.editedName = editedName - + if let name = name, feed.name == nil { + feed.name = name + } + if let editedName = editedName, feed.editedName == nil { + feed.editedName = editedName + } + return feed } @@ -696,13 +693,13 @@ private extension Account { idDictionary[feed.feedID] = feed } - urlToFeedDictionary = urlDictionary +// urlToFeedDictionary = urlDictionary idToFeedDictionary = idDictionary } func addToFeedDictionaries(_ feed: Feed) { - urlToFeedDictionary[feed.url] = feed +// urlToFeedDictionary[feed.url] = feed idToFeedDictionary[feed.feedID] = feed } @@ -798,10 +795,10 @@ private extension Account { extension Account { - public func existingFeed(withURL url: String) -> Feed? { - - return urlToFeedDictionary[url] - } +// public func existingFeed(withURL url: String) -> Feed? { +// +// return urlToFeedDictionary[url] +// } public func existingFeed(with feedID: String) -> Feed? {