Init Folder with an Account rather than an accountID.

This commit is contained in:
Brent Simmons 2017-09-28 06:53:01 -07:00
parent 48543bcfd6
commit 1ec3484a95
2 changed files with 8 additions and 13 deletions

View File

@ -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) {

View File

@ -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 {