Use hash(into…) instead of a hashValue instance variable.
This commit is contained in:
parent
f5637dc353
commit
142774f5ae
|
@ -27,10 +27,7 @@ public struct Article: Hashable {
|
||||||
public let authors: Set<Author>?
|
public let authors: Set<Author>?
|
||||||
public let attachments: Set<Attachment>?
|
public let attachments: Set<Attachment>?
|
||||||
public let status: ArticleStatus
|
public let status: ArticleStatus
|
||||||
public var hashValue: Int {
|
|
||||||
return articleID.hashValue
|
|
||||||
}
|
|
||||||
|
|
||||||
public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set<Author>?, attachments: Set<Attachment>?, status: ArticleStatus) {
|
public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set<Author>?, attachments: Set<Attachment>?, status: ArticleStatus) {
|
||||||
|
|
||||||
self.accountID = accountID
|
self.accountID = accountID
|
||||||
|
@ -59,20 +56,23 @@ public struct Article: Hashable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func calculatedArticleID(feedID: String, uniqueID: String) -> String {
|
public static func calculatedArticleID(feedID: String, uniqueID: String) -> String {
|
||||||
|
|
||||||
return databaseIDWithString("\(feedID) \(uniqueID)")
|
return databaseIDWithString("\(feedID) \(uniqueID)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Hashable
|
||||||
|
|
||||||
|
public func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(articleID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Set where Element == Article {
|
public extension Set where Element == Article {
|
||||||
|
|
||||||
public func articleIDs() -> Set<String> {
|
public func articleIDs() -> Set<String> {
|
||||||
|
|
||||||
return Set<String>(map { $0.articleID })
|
return Set<String>(map { $0.articleID })
|
||||||
}
|
}
|
||||||
|
|
||||||
public func unreadArticles() -> Set<Article> {
|
public func unreadArticles() -> Set<Article> {
|
||||||
|
|
||||||
let articles = self.filter { !$0.status.read }
|
let articles = self.filter { !$0.status.read }
|
||||||
return Set(articles)
|
return Set(articles)
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,7 @@ public extension Set where Element == Article {
|
||||||
|
|
||||||
public extension Array where Element == Article {
|
public extension Array where Element == Article {
|
||||||
|
|
||||||
public func articleIDs() -> [String] {
|
public func articleIDs() -> [String] {
|
||||||
|
|
||||||
return map { $0.articleID }
|
return map { $0.articleID }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue