From 1ec3484a95efdacad116d5bf0d1d52e410875959 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 28 Sep 2017 06:53:01 -0700 Subject: [PATCH] Init Folder with an Account rather than an accountID. --- Frameworks/Account/Account.swift | 1 + Frameworks/Account/Folder.swift | 20 +++++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 9a81d9cf5..96606a0c3 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -37,6 +37,7 @@ public final class Account: DisplayNameProvider, Hashable { var feedIDDictionary = [String: Feed]() var username: String? var refreshInProgress = false + var supportsSubFolders; init?(dataFolder: String, settingsFile: String, type: AccountType, accountID: String) { diff --git a/Frameworks/Account/Folder.swift b/Frameworks/Account/Folder.swift index 997cd810c..280db75bc 100644 --- a/Frameworks/Account/Folder.swift +++ b/Frameworks/Account/Folder.swift @@ -11,16 +11,10 @@ import Data public final class Folder: DisplayNameProvider, UnreadCountProvider { - public let accountID: String + public let account: Account var children = [Any]() var name: String? - public var account: Account? { - get { - return accountWithID(accountID) - } - } - // MARK: - DisplayNameProvider public var nameForDisplay: String { @@ -42,10 +36,10 @@ public final class Folder: DisplayNameProvider, UnreadCountProvider { // MARK: - Init - init(accountID: String, nameForDisplay: String) { + init(account: Account, name: String) { - self.accountID = accountID - self.nameForDisplay = nameForDisplay + self.account = account + self.name = name } // MARK: - Disk Dictionary @@ -58,10 +52,10 @@ public final class Folder: DisplayNameProvider, UnreadCountProvider { convenience public init?(account: Account, dictionary: [String: Any]) { - self.name = dictionary[Key.name] + self.name = dictionary[Key.name] as? String - if let childrenArray = dictionary[Key.childrenKey] { - self.childObjects = account.objects(with: childrenArray) + if let childrenArray = dictionary[Key.childrenKey] as? [String: Any] { + self.children = account.objects(with: childrenArray) } if let savedUnreadCount = dictionary[Key.unreadCount] as? Int {