diff --git a/Frameworks/Data/Protocols/UnreadCountProvider.swift b/Frameworks/Account/UnreadCountProvider.swift similarity index 100% rename from Frameworks/Data/Protocols/UnreadCountProvider.swift rename to Frameworks/Account/UnreadCountProvider.swift diff --git a/Frameworks/Data/AccountInfo.swift b/Frameworks/Data/AccountInfo.swift index 499d84aca..85a295fd0 100644 --- a/Frameworks/Data/AccountInfo.swift +++ b/Frameworks/Data/AccountInfo.swift @@ -8,7 +8,15 @@ import Foundation -public typealias AccountInfo = [String: AnyObject] +public struct AccountInfo: Equatable { + + var dictionary: [String: AnyObject]? + + public static func ==(lhs: AccountInfo, rhs: AccountInfo) -> Bool { + + return true // TODO + } +} // AccountInfo is a plist-compatible dictionary that’s stored as a binary plist in the database. diff --git a/Frameworks/Data/ArticleStatus.swift b/Frameworks/Data/ArticleStatus.swift index b3413c86f..97d282b0b 100644 --- a/Frameworks/Data/ArticleStatus.swift +++ b/Frameworks/Data/ArticleStatus.swift @@ -54,9 +54,9 @@ public struct ArticleStatus: Hashable { return userDeleted } } - else if let flag = accountInfo?[key] as? Bool { - return flag - } +// else if let flag = accountInfo?[key] as? Bool { +// return flag +// } return false } diff --git a/Frameworks/Data/Data.xcodeproj/project.pbxproj b/Frameworks/Data/Data.xcodeproj/project.pbxproj index 744cd53f6..44a393010 100644 --- a/Frameworks/Data/Data.xcodeproj/project.pbxproj +++ b/Frameworks/Data/Data.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 844BEE981F0AB4F8004AB7CD /* AccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE941F0AB4F8004AB7CD /* AccountDelegate.swift */; }; 844BEE991F0AB4F8004AB7CD /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE951F0AB4F8004AB7CD /* Container.swift */; }; 844BEE9A1F0AB4F8004AB7CD /* DisplayNameProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE961F0AB4F8004AB7CD /* DisplayNameProvider.swift */; }; - 844BEE9B1F0AB4F8004AB7CD /* UnreadCountProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE971F0AB4F8004AB7CD /* UnreadCountProvider.swift */; }; 848935221F6249AC00CEBD24 /* AccountInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848935211F6249AC00CEBD24 /* AccountInfo.swift */; }; /* End PBXBuildFile section */ @@ -81,7 +80,6 @@ 844BEE941F0AB4F8004AB7CD /* AccountDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountDelegate.swift; sourceTree = ""; }; 844BEE951F0AB4F8004AB7CD /* Container.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; 844BEE961F0AB4F8004AB7CD /* DisplayNameProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplayNameProvider.swift; sourceTree = ""; }; - 844BEE971F0AB4F8004AB7CD /* UnreadCountProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnreadCountProvider.swift; sourceTree = ""; }; 844BEE9C1F0AB512004AB7CD /* RSCore.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSCore.xcodeproj; path = ../RSCore/RSCore.xcodeproj; sourceTree = ""; }; 848935211F6249AC00CEBD24 /* AccountInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountInfo.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -162,7 +160,6 @@ 844BEE941F0AB4F8004AB7CD /* AccountDelegate.swift */, 844BEE951F0AB4F8004AB7CD /* Container.swift */, 844BEE961F0AB4F8004AB7CD /* DisplayNameProvider.swift */, - 844BEE971F0AB4F8004AB7CD /* UnreadCountProvider.swift */, ); path = Protocols; sourceTree = ""; @@ -342,7 +339,6 @@ 844BEE811F0AB4D0004AB7CD /* Author.swift in Sources */, 844BEE921F0AB4EF004AB7CD /* OPMLRepresentable.swift in Sources */, 840405CA1F1A8E4300DF0296 /* DatabaseID.swift in Sources */, - 844BEE9B1F0AB4F8004AB7CD /* UnreadCountProvider.swift in Sources */, 844BEE851F0AB4DB004AB7CD /* ArticleStatus.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Frameworks/Data/Feed.swift b/Frameworks/Data/Feed.swift index 6506d5abc..f507830ff 100644 --- a/Frameworks/Data/Feed.swift +++ b/Frameworks/Data/Feed.swift @@ -9,7 +9,7 @@ import Foundation import RSCore -public final class Feed: UnreadCountProvider, DisplayNameProvider, Hashable { +public final class Feed: DisplayNameProvider, Hashable { public let accountID: String public let url: String @@ -27,13 +27,13 @@ public final class Feed: UnreadCountProvider, DisplayNameProvider, Hashable { } } - public var unreadCount = 0 { - didSet { - if unreadCount != oldValue { - postUnreadCountDidChangeNotification() - } - } - } +// public var unreadCount = 0 { +// didSet { +// if unreadCount != oldValue { +// postUnreadCountDidChangeNotification() +// } +// } +// } public init(accountID: String, url: String, feedID: String) { @@ -43,15 +43,15 @@ public final class Feed: UnreadCountProvider, DisplayNameProvider, Hashable { self.hashValue = accountID.hashValue ^ url.hashValue ^ feedID.hashValue } - public func updateUnreadCount() { - - unreadCount = articles.reduce(0) { (result, oneArticle) -> Int in - if let read = oneArticle.status?.read, !read { - return result + 1 - } - return result - } - } +// public func updateUnreadCount() { +// +// unreadCount = articles.reduce(0) { (result, oneArticle) -> Int in +// if let read = oneArticle.status?.read, !read { +// return result + 1 +// } +// return result +// } +// } public class func ==(lhs: Feed, rhs: Feed) -> Bool { diff --git a/Frameworks/Data/Folder.swift b/Frameworks/Data/Folder.swift index 9c3a82098..a7ee2effc 100644 --- a/Frameworks/Data/Folder.swift +++ b/Frameworks/Data/Folder.swift @@ -8,7 +8,7 @@ import Foundation -public final class Folder: UnreadCountProvider { +public final class Folder { public let accountID: String public var nameForDisplay: String @@ -19,36 +19,34 @@ public final class Folder: UnreadCountProvider { self.accountID = accountID self.nameForDisplay = nameForDisplay - NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) +// NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) } // MARK: Notifications - @objc dynamic public func unreadCountDidChange(_ note: Notification) { - - guard let obj = note.object else { - return - } - let potentialChild = obj as AnyObject - if isChild(potentialChild) { - updateUnreadCount() - } - } - - // MARK: UnreadCountProvider - - public var unreadCount = 0 { - didSet { - if unreadCount != oldValue { - postUnreadCountDidChangeNotification() - } - } - } - - public func updateUnreadCount() { - - unreadCount = calculateUnreadCount(childObjects) - } +// @objc dynamic public func unreadCountDidChange(_ note: Notification) { +// +// guard let obj = note.object else { +// return +// } +// let potentialChild = obj as AnyObject +// if isChild(potentialChild) { +// updateUnreadCount() +// } +// } + +// public var unreadCount = 0 { +// didSet { +// if unreadCount != oldValue { +// postUnreadCountDidChangeNotification() +// } +// } +// } + +// public func updateUnreadCount() { +// +// unreadCount = calculateUnreadCount(childObjects) +// } } extension Folder: Container {