diff --git a/Feedly/Sources/Feedly/Models/FeedlyCategory.swift b/Feedly/Sources/Feedly/Models/FeedlyCategory.swift index ea7068e1b..72abb7d62 100644 --- a/Feedly/Sources/Feedly/Models/FeedlyCategory.swift +++ b/Feedly/Sources/Feedly/Models/FeedlyCategory.swift @@ -8,8 +8,12 @@ import Foundation -public struct FeedlyCategory: Decodable, Sendable { +public struct FeedlyCategory: Decodable, Sendable, Equatable { public let label: String public let id: String + + public static func ==(lhs: FeedlyCategory, rhs: FeedlyCategory) -> Bool { + lhs.label == rhs.label && lhs.id == rhs.id + } } diff --git a/Feedly/Sources/Feedly/Models/FeedlyEntry.swift b/Feedly/Sources/Feedly/Models/FeedlyEntry.swift index 385655ee5..933886992 100644 --- a/Feedly/Sources/Feedly/Models/FeedlyEntry.swift +++ b/Feedly/Sources/Feedly/Models/FeedlyEntry.swift @@ -8,7 +8,7 @@ import Foundation -public struct FeedlyEntry: Decodable, Sendable { +public struct FeedlyEntry: Decodable, Sendable, Hashable { /// the unique, immutable ID for this particular article. public let id: String @@ -16,7 +16,7 @@ public struct FeedlyEntry: Decodable, Sendable { /// the article’s title. This string does not contain any HTML markup. public let title: String? - public struct Content: Decodable, Sendable { + public struct Content: Decodable, Sendable, Equatable { public enum Direction: String, Decodable, Sendable { case leftToRight = "ltr" @@ -25,6 +25,10 @@ public struct FeedlyEntry: Decodable, Sendable { public let content: String? public let direction: Direction? + + public static func ==(lhs: Content, rhs: Content) -> Bool { + lhs.content == rhs.content && lhs.direction == rhs.direction + } } /// This object typically has two values: “content” for the content itself, and “direction” (“ltr” for left-to-right, “rtl” for right-to-left). The content itself contains sanitized HTML markup. @@ -63,4 +67,13 @@ public struct FeedlyEntry: Decodable, Sendable { /// A list of media links (videos, images, sound etc) provided by the feed. Some entries do not have a summary or content, only a collection of media links. public let enclosure: [FeedlyLink]? + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + } + + public static func ==(lhs: FeedlyEntry, rhs: FeedlyEntry) -> Bool { + + lhs.id == rhs.id && lhs.title == rhs.title && lhs.content == rhs.content && lhs.summary == rhs.summary && lhs.author == rhs.author && lhs.crawled == rhs.crawled && lhs.recrawled == rhs.recrawled && lhs.origin == rhs.origin && lhs.canonical == rhs.canonical && lhs.alternate == rhs.alternate && lhs.unread == rhs.unread && lhs.tags == rhs.tags && lhs.categories == rhs.categories && lhs.enclosure == rhs.enclosure + } } diff --git a/Feedly/Sources/Feedly/Models/FeedlyLink.swift b/Feedly/Sources/Feedly/Models/FeedlyLink.swift index 3924869da..49337ca53 100644 --- a/Feedly/Sources/Feedly/Models/FeedlyLink.swift +++ b/Feedly/Sources/Feedly/Models/FeedlyLink.swift @@ -8,7 +8,7 @@ import Foundation -public struct FeedlyLink: Decodable, Sendable { +public struct FeedlyLink: Decodable, Sendable, Equatable { public let href: String @@ -16,4 +16,8 @@ public struct FeedlyLink: Decodable, Sendable { /// When `nil`, it's probably a web page? /// https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ public let type: String? + + public static func ==(lhs: FeedlyLink, rhs: FeedlyLink) -> Bool { + lhs.href == rhs.href && lhs.type == rhs.type + } } diff --git a/Feedly/Sources/Feedly/Models/FeedlyOrigin.swift b/Feedly/Sources/Feedly/Models/FeedlyOrigin.swift index 1cc8bc587..fe02e5e11 100644 --- a/Feedly/Sources/Feedly/Models/FeedlyOrigin.swift +++ b/Feedly/Sources/Feedly/Models/FeedlyOrigin.swift @@ -8,9 +8,14 @@ import Foundation -public struct FeedlyOrigin: Decodable, Sendable { +public struct FeedlyOrigin: Decodable, Sendable, Equatable { public let title: String? public let streamID: String? - public let htmlUrl: String? + public let htmlURL: String? + + public static func ==(lhs: FeedlyOrigin, rhs: FeedlyOrigin) -> Bool { + + lhs.title == rhs.title && lhs.streamID == rhs.streamID && lhs.htmlURL == rhs.htmlURL + } } diff --git a/Feedly/Sources/Feedly/Models/FeedlyTag.swift b/Feedly/Sources/Feedly/Models/FeedlyTag.swift index 3b6c16064..20cb3463b 100644 --- a/Feedly/Sources/Feedly/Models/FeedlyTag.swift +++ b/Feedly/Sources/Feedly/Models/FeedlyTag.swift @@ -8,8 +8,12 @@ import Foundation -public struct FeedlyTag: Decodable, Sendable { +public struct FeedlyTag: Decodable, Sendable, Equatable { public let id: String public let label: String? + + public static func ==(lhs: FeedlyTag, rhs: FeedlyTag) -> Bool { + lhs.id == rhs.id && lhs.label == rhs.label + } }