Make folder.account weak and optional.
This commit is contained in:
parent
c5c28464e0
commit
8d5e568cde
|
@ -147,8 +147,8 @@ private extension AddFeedController {
|
|||
if let account = container as? Account {
|
||||
return AccountAndFolderSpecifier(account: account, folder: nil)
|
||||
}
|
||||
if let folder = container as? Folder {
|
||||
return AccountAndFolderSpecifier(account: folder.account, folder: folder)
|
||||
if let folder = container as? Folder, let account = folder.account {
|
||||
return AccountAndFolderSpecifier(account: account, folder: folder)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -194,8 +194,8 @@ private extension SidebarViewController {
|
|||
if let feed = object as? Feed, let account = feed.account {
|
||||
account.updateUnreadCounts(for: Set([feed]))
|
||||
}
|
||||
else if let folder = object as? Folder {
|
||||
folder.account.updateUnreadCounts(for: folder.flattenedFeeds())
|
||||
else if let folder = object as? Folder, let account = folder.account {
|
||||
account.updateUnreadCounts(for: folder.flattenedFeeds())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import Data
|
|||
|
||||
public final class Folder: DisplayNameProvider, Container, UnreadCountProvider {
|
||||
|
||||
public let account: Account
|
||||
public weak var account: Account?
|
||||
public var children = [AnyObject]()
|
||||
var name: String?
|
||||
static let untitledName = NSLocalizedString("Untitled ƒ", comment: "Folder name")
|
||||
|
@ -19,7 +19,10 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider {
|
|||
// MARK: - Fetching Articles
|
||||
|
||||
public func fetchArticles() -> Set<Article> {
|
||||
|
||||
|
||||
guard let account = account else {
|
||||
return Set<Article>()
|
||||
}
|
||||
return account.fetchArticles(folder: self)
|
||||
}
|
||||
|
||||
|
@ -76,7 +79,11 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider {
|
|||
|
||||
var dictionary: [String: Any] {
|
||||
get {
|
||||
|
||||
var d = [String: Any]()
|
||||
guard let account = account else {
|
||||
return d
|
||||
}
|
||||
|
||||
if let name = name {
|
||||
d[Key.name] = name
|
||||
|
|
Loading…
Reference in New Issue