Use synthesized init, Equatable, Hashable.
This commit is contained in:
parent
6c336627de
commit
30972ef435
@ -59,20 +59,6 @@ public struct Article: Hashable {
|
||||
|
||||
return databaseIDWithString("\(feedID) \(uniqueID)")
|
||||
}
|
||||
|
||||
// MARK: - Hashable
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(accountID)
|
||||
hasher.combine(articleID)
|
||||
}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
public static func ==(lhs: Article, rhs: Article) -> Bool {
|
||||
|
||||
return lhs.articleID == rhs.articleID && lhs.accountID == rhs.accountID && lhs.feedID == rhs.feedID && lhs.uniqueID == rhs.uniqueID && lhs.title == rhs.title && lhs.contentHTML == rhs.contentHTML && lhs.url == rhs.url && lhs.externalURL == rhs.externalURL && lhs.summary == rhs.summary && lhs.imageURL == rhs.imageURL && lhs.bannerImageURL == rhs.bannerImageURL && lhs.datePublished == rhs.datePublished && lhs.authors == rhs.authors && lhs.attachments == rhs.attachments
|
||||
}
|
||||
}
|
||||
|
||||
public extension Set where Element == Article {
|
||||
|
@ -76,7 +76,7 @@ public final class ArticleStatus: Hashable {
|
||||
// MARK: - Equatable
|
||||
|
||||
public static func ==(lhs: ArticleStatus, rhs: ArticleStatus) -> Bool {
|
||||
|
||||
|
||||
return lhs.articleID == rhs.articleID && lhs.dateArrived == rhs.dateArrived && lhs.read == rhs.read && lhs.starred == rhs.starred && lhs.userDeleted == rhs.userDeleted
|
||||
}
|
||||
}
|
||||
|
@ -51,17 +51,4 @@ public struct Attachment: Hashable {
|
||||
self.attachmentID = databaseIDWithString(s)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Hashable
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(attachmentID)
|
||||
}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
public static func ==(lhs: Attachment, rhs: Attachment) -> Bool {
|
||||
|
||||
return lhs.attachmentID == rhs.attachmentID
|
||||
}
|
||||
}
|
||||
|
@ -78,19 +78,6 @@ public struct Author: Hashable {
|
||||
let authors = diskArray.compactMap { Author(dictionary: $0) }
|
||||
return authors.isEmpty ? nil : Set(authors)
|
||||
}
|
||||
|
||||
// MARK: - Hashable
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(authorID)
|
||||
}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
public static func ==(lhs: Author, rhs: Author) -> Bool {
|
||||
|
||||
return lhs.authorID == rhs.authorID
|
||||
}
|
||||
}
|
||||
|
||||
extension Set where Element == Author {
|
||||
|
@ -28,38 +28,6 @@ struct DatabaseArticle: Hashable {
|
||||
let datePublished: Date?
|
||||
let dateModified: Date?
|
||||
let status: ArticleStatus
|
||||
|
||||
init(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?, status: ArticleStatus) {
|
||||
|
||||
self.articleID = articleID
|
||||
self.feedID = feedID
|
||||
self.uniqueID = uniqueID
|
||||
self.title = title
|
||||
self.contentHTML = contentHTML
|
||||
self.contentText = contentText
|
||||
self.url = url
|
||||
self.externalURL = externalURL
|
||||
self.summary = summary
|
||||
self.imageURL = imageURL
|
||||
self.bannerImageURL = bannerImageURL
|
||||
self.datePublished = datePublished
|
||||
self.dateModified = dateModified
|
||||
self.status = status
|
||||
}
|
||||
|
||||
// MARK: - Hashable
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(articleID)
|
||||
}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
static func ==(lhs: DatabaseArticle, rhs: DatabaseArticle) -> Bool {
|
||||
|
||||
return lhs.articleID == rhs.articleID && lhs.feedID == rhs.feedID && lhs.uniqueID == rhs.uniqueID && lhs.title == rhs.title && lhs.contentHTML == rhs.contentHTML && lhs.contentText == rhs.contentText && lhs.url == rhs.url && lhs.externalURL == rhs.externalURL && lhs.summary == rhs.summary && lhs.imageURL == rhs.imageURL && lhs.bannerImageURL == rhs.bannerImageURL && lhs.datePublished == rhs.datePublished && lhs.dateModified == rhs.dateModified && lhs.status == rhs.status
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user